merkNotificationBundle icon indicating copy to clipboard operation
merkNotificationBundle copied to clipboard

Adding classname aliases to prevent conflicts

Open brentc opened this issue 13 years ago • 1 comments

Model\NotificationEventManager was conflicting with Entity\NotificiationEventManager when building the bootstrap cache.

$ php app/console cache:clear
Clearing the cache for the dev environment with debug true

PHP Fatal error:  Cannot use merk\NotificationBundle\Model\NotificationEventManager as NotificationEventManager because the name is already in use in /Users/brent/Sites/Cure8/vendor/bundles/merk/NotificationBundle/Entity/NotificationEventListener.php on line 19

PHP Stack trace:
PHP   1. {main}() /Users/brent/Sites/Cure8/app/console:0
PHP   2. Symfony\Component\Console\Application->run() /Users/brent/Sites/Cure8/app/console:16
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Component/Console/Application.php:118
PHP   4. Symfony\Component\Console\Application->doRun() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
PHP   5. Symfony\Component\Console\Command\Command->run() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Component/Console/Application.php:194
PHP   6. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:224
PHP   7. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:72
PHP   8. Symfony\Component\HttpKernel\Kernel->boot() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:94
PHP   9. Symfony\Component\HttpKernel\Kernel->initializeContainer() /Users/brent/Sites/Cure8/app/bootstrap.php.cache:513
PHP  10. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() /Users/brent/Sites/Cure8/app/bootstrap.php.cache:791
PHP  11. Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer->warmUp() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:47
PHP  12. Symfony\Bundle\DoctrineBundle\Registry->getEntityManagers() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php:51
PHP  13. Symfony\Component\DependencyInjection\Container->get() /Users/brent/Sites/Cure8/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Registry.php:136
PHP  14. appDevDebugProjectContainer__50241fe459b63__->getDoctrine_Orm_DefaultEntityManagerService() /Users/brent/Sites/Cure8/app/bootstrap.php.cache:190
PHP  15. Symfony\Component\DependencyInjection\Container->get() /Users/brent/Sites/Cure8/app/cache/dev_new/appDevDebugProjectContainer__50241fe459b63__.php:706
PHP  16. appDevDebugProjectContainer__50241fe459b63__->getDoctrine_Dbal_DefaultConnectionService() /Users/brent/Sites/Cure8/app/bootstrap.php.cache:190
PHP  17. Symfony\Component\ClassLoader\DebugUniversalClassLoader->loadClass() /Users/brent/Sites/Cure8/app/bootstrap.php.cache:0

This only seems to happen when building a new bootstrap cache. I suspect because in the process of building the bootstrap the Entity\NotificationEventManager was being loaded sometime before the Entity\NotificationEventListener is loaded, at which point 'using' the Model\NotificationEventManager brings it within the Entity\ namespace, causing the conflict.

Adding the alias resolves the error.

brentc avatar Aug 10 '12 01:08 brentc

Azer- mentions this issue in #7

brentc avatar Aug 10 '12 01:08 brentc