3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EC-CUBE4でプラグインのEntityを拡張しようとしたらproxyの生成でコケて困った時の対応

Posted at

買ったプラグインにちょっと機能的な不満があり、カスタマイズしようとしたら、proxyの生成でコケたのでその対応をメモしときます。

./bin/console eccube:generate:proxies
Exception trace:
  at /var/www/html/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php:314
 PhpCsFixer\Tokenizer\Tokens->offsetSet() at /var/www/html/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php:937
 PhpCsFixer\Tokenizer\Tokens->clearAt() at /var/www/html/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php:1147
 PhpCsFixer\Tokenizer\Tokens->clearRange() at /var/www/html/src/Eccube/Service/EntityProxyService.php:301
 Eccube\Service\EntityProxyService->removeClassExistsBlock() at /var/www/html/src/Eccube/Service/EntityProxyService.php:84
 Eccube\Service\EntityProxyService->generate() at /var/www/html/src/Eccube/Command/GenerateProxyCommand.php:60
 Eccube\Command\GenerateProxyCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1005
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:255
 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:74
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /var/www/html/bin/console:37

何がおきてるかと言うと、proxy生成する際にphp-cs-fixer使ってコードを整形してるんだけど、そこでうまく整形できずにエラーになってる。たぶんEC-CUBE側のバグ

php-cs-fixerをアップデート

composer update friendsofphp/php-cs-fixer

今回はここで

Compile Error: Declaration of EntityManager_9a5be93::getProxyInitializer()   
must be compatible with ProxyManager\Proxy\LazyLoadingInterface::getProxyIn  
itializer(): ?Closure 

が出てもう一手間増えた...

手動でfixする

proxyの中のEntityにTrait追加して、まとめてfixしようとしてコケてるので、proxy生成前に手動でそれぞれfixする。

./vendor/bin/php-cs-fixer fix ./app/proxy/entity
./vendor/bin/php-cs-fixer fix ./app/Plugin

プラグイン指定した方が良いかも。 面倒ならプラグインディレクトリまるっとfix

再度プロキシ生成

./bin/console eccube:generate:proxies

無事、プロキシ生成、スキーマの更新できました。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?