Doctrine Common
  1. Doctrine Common
  2. DCOM-168

ignoredAnnotationNames doesn't work in Annotation loop

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: Annotations
    • Labels:
      None
    • Environment:
      Mac OSX 10.6.8

      Description

      I'm just starting out with Doctrine, so my setup is a bit messy, but hopefully someone can figure out what is relevant from all my code.

      Basically, I'm using Annotations on Doctrine ORM, and am integrating with Gedmo for several of their extensions.

      I can run the CLI tool and update the schema, but when running via my web server, I'm getting the following error:

      object(Doctrine\Common\Annotations\AnnotationException)[150]
        protected 'message' => string '[Semantical Error] The annotation "@Entity" in class Innertube\Models\Device was never imported. Did you maybe forget to add a "use" statement for this annotation?' (length=163)
        private 'string' (Exception) => string '' (length=0)
        protected 'code' => int 0
        protected 'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php' (length=211)
        protected 'line' => int 52
        private 'trace' (Exception) => 
          array
            0 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                'line' => int 592
                'function' => string 'semanticalError' (length=15)
                'class' => string 'Doctrine\Common\Annotations\AnnotationException' (length=47)
                'type' => string '::' (length=2)
                'args' => 
                  array
                    ...
            1 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                'line' => int 533
                'function' => string 'Annotation' (length=10)
                'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            2 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                'line' => int 297
                'function' => string 'Annotations' (length=11)
                'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            3 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php' (length=208)
                'line' => int 151
                'function' => string 'parse' (length=5)
                'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            4 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php' (length=204)
                'line' => int 86
                'function' => string 'getClassAnnotations' (length=19)
                'class' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            5 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php' (length=205)
                'line' => int 61
                'function' => string 'getClassAnnotations' (length=19)
                'class' => string 'Doctrine\Common\Annotations\CachedReader' (length=40)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            6 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=202)
                'line' => int 112
                'function' => string 'loadMetadataForClass' (length=20)
                'class' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            7 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                'line' => int 302
                'function' => string 'doLoadMetadata' (length=14)
                'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            8 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                'line' => int 205
                'function' => string 'loadMetadata' (length=12)
                'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            9 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                'line' => int 268
                'function' => string 'getMetadataFor' (length=14)
                'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            10 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                'line' => int 682
                'function' => string 'getClassMetadata' (length=16)
                'class' => string 'Doctrine\ORM\EntityManager' (length=26)
                'type' => string '->' (length=2)
                'args' => 
                  array
                    ...
            11 => 
              array
                'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/api/routes/devices.php' (length=108)
                'line' => int 16
                'function' => string 'getRepository' (length=13)
                'class' => string 'Doctrine\ORM\EntityManager' (length=26)
      

      The call that initiates this is getRepository(), which IS NOT in the CLI.

      I've tracked it down to the fact that DocParser is not getting the list of names to ignore.

      Oddly, it gets it the first time that it's called by AnnotationReader. However, DocParser->parse() calls $this->Annotations(), which calls $this->Annotation(), calls $this->collectAnnotationMetadata(), which then creates a new parser

      self::$metadataParser = new self();

      and eventually parses it

      self::$metadataParser->parse()

      , but DOES NOT pass its ignorednames.

      This seems like an oversight, but it clearly works for a lot of people. My configuration code is:

                      if (self::$isDevMode) {
      			$cache = new \Doctrine\Common\Cache\ArrayCache;
      		} else {
      			$cache = new \Doctrine\Common\Cache\ApcCache;
      		}
      
      		\Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');
      
      		AnnotationRegistry::registerFile(__DIR__ . "/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
      		\Gedmo\DoctrineExtensions::registerAnnotations();
      
      		
      
      		$annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
      		$cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);
      
      
      
      		$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, self::$namespaceArray);
      
      		$config = new \Doctrine\ORM\Configuration;
      		$config->setProxyNamespace('Proxy');
      		$config->setAutoGenerateProxyClasses(self::$isDevMode); // this can be based on production config.
      		// register metadata driver
      		$config->setMetadataDriverImpl($annotationDriver);
      		// use our allready initialized cache driver
      		$config->setMetadataCacheImpl($cache);
      		$config->setQueryCacheImpl($cache);
      
      		if (defined('DIR_FILES_CACHE')) {
      			$config->setProxyDir(DIR_FILES_CACHE);
      		} else {
      			$config->setProxyDir(sys_get_temp_dir());
      		}
      
      		// create event manager and hook prefered extension listeners
      		$evm = new \Doctrine\Common\EventManager();
      
      		$prefix = new TablePrefix(null);
      		$prefix->useNamespace(true);
      		$evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefix);
      
      
      		$blameableListener = new \Gedmo\Blameable\BlameableListener();
      		$blameableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
      		//class_exists makes this usable with the command-line
      		if (class_exists('\User') && ($u = new \User()) != false) {
      			$blameableListener->setUserValue($u->getUserID());
      		}
      		$evm->addEventSubscriber($blameableListener);
      
      
      		$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
      		$timestampableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
      		$evm->addEventSubscriber($timestampableListener);
      
      		$config->addFilter('soft-deleteable', '\Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');
      
      
      		return EntityManager::create($connectionOptions, $config, $evm);
      

      and the entity is (which sets up the repository) is:

      namespace Innertube\Models;
      defined('C5_EXECUTE') or die('Access Denied.');
      
      use Doctrine\ORM\Mapping as ORM;
      use Doctrine\Common\Collections\ArrayCollection;
      use Gedmo\Mapping\Annotation as Gedmo;
      
      /**
       * @ORM\Entity(repositoryClass="DeviceRepository") @ORM\Table(name="Devices")
       * @Gedmo\SoftDeleteable(fieldName="deletedOn")
       **/
      class Device {
      

      and the repository is:

      namespace Innertube\Models;
      defined('C5_EXECUTE') or die('Access Denied.');
      
      use Doctrine\ORM\EntityRepository;
      
      class DeviceRepository extends EntityRepository {
      

        Activity

        James S created issue -
        Marco Pivetta made changes -
        Field Original Value New Value
        Description I'm just starting out with Doctrine, so my setup is a bit messy, but hopefully someone can figure out what is relevant from all my code.

        Basically, I'm using Annotations on Doctrine ORM, and am integrating with Gedmo for several of their extensions.

        I can run the CLI tool and update the schema, but when running via my web server, I'm getting the following error:

        object(Doctrine\Common\Annotations\AnnotationException)[150]
          protected 'message' => string '[Semantical Error] The annotation "@Entity" in class Innertube\Models\Device was never imported. Did you maybe forget to add a "use" statement for this annotation?' (length=163)
          private 'string' (Exception) => string '' (length=0)
          protected 'code' => int 0
          protected 'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php' (length=211)
          protected 'line' => int 52
          private 'trace' (Exception) =>
            array
              0 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 592
                  'function' => string 'semanticalError' (length=15)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationException' (length=47)
                  'type' => string '::' (length=2)
                  'args' =>
                    array
                      ...
              1 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 533
                  'function' => string 'Annotation' (length=10)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              2 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 297
                  'function' => string 'Annotations' (length=11)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              3 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php' (length=208)
                  'line' => int 151
                  'function' => string 'parse' (length=5)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              4 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php' (length=204)
                  'line' => int 86
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              5 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php' (length=205)
                  'line' => int 61
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\CachedReader' (length=40)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              6 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=202)
                  'line' => int 112
                  'function' => string 'loadMetadataForClass' (length=20)
                  'class' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              7 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 302
                  'function' => string 'doLoadMetadata' (length=14)
                  'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              8 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 205
                  'function' => string 'loadMetadata' (length=12)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              9 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 268
                  'function' => string 'getMetadataFor' (length=14)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              10 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 682
                  'function' => string 'getClassMetadata' (length=16)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              11 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/api/routes/devices.php' (length=108)
                  'line' => int 16
                  'function' => string 'getRepository' (length=13)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)

        The call that initiates this is getRepository(), which IS NOT in the CLI.

        I've tracked it down to the fact that DocParser is not getting the list of names to ignore.

        Oddly, it gets it the first time that it's called by AnnotationReader. However, DocParser->parse() calls $this->Annotations(), which calls $this->Annotation(), calls $this->collectAnnotationMetadata(), which then creates a new parser (self::$metadataParser = new self();) and eventually parses it (self::$metadataParser->parse()), but DOES NOT pass its ignorednames.

        This seems like an oversight, but it clearly works for a lot of people. My configuration code is:

        if (self::$isDevMode) {
        $cache = new \Doctrine\Common\Cache\ArrayCache;
        } else {
        $cache = new \Doctrine\Common\Cache\ApcCache;
        }

        \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');

        AnnotationRegistry::registerFile(__DIR__ . "/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
        \Gedmo\DoctrineExtensions::registerAnnotations();



        $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
        $cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);



        $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, self::$namespaceArray);

        $config = new \Doctrine\ORM\Configuration;
        $config->setProxyNamespace('Proxy');
        $config->setAutoGenerateProxyClasses(self::$isDevMode); // this can be based on production config.
        // register metadata driver
        $config->setMetadataDriverImpl($annotationDriver);
        // use our allready initialized cache driver
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);

        if (defined('DIR_FILES_CACHE')) {
        $config->setProxyDir(DIR_FILES_CACHE);
        } else {
        $config->setProxyDir(sys_get_temp_dir());
        }

        // create event manager and hook prefered extension listeners
        $evm = new \Doctrine\Common\EventManager();

        $prefix = new TablePrefix(null);
        $prefix->useNamespace(true);
        $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefix);


        $blameableListener = new \Gedmo\Blameable\BlameableListener();
        $blameableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        //class_exists makes this usable with the command-line
        if (class_exists('\User') && ($u = new \User()) != false) {
        $blameableListener->setUserValue($u->getUserID());
        }
        $evm->addEventSubscriber($blameableListener);


        $timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
        $timestampableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        $evm->addEventSubscriber($timestampableListener);

        $config->addFilter('soft-deleteable', '\Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');


        return EntityManager::create($connectionOptions, $config, $evm);

        and the entity is (which sets up the repository) is:

        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\Mapping as ORM;
        use Doctrine\Common\Collections\ArrayCollection;
        use Gedmo\Mapping\Annotation as Gedmo;

        /**
         * @ORM\Entity(repositoryClass="DeviceRepository") @ORM\Table(name="Devices")
         * @Gedmo\SoftDeleteable(fieldName="deletedOn")
         **/
        class Device {

        and the repository is:

        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\EntityRepository;

        class DeviceRepository extends EntityRepository {
        I'm just starting out with Doctrine, so my setup is a bit messy, but hopefully someone can figure out what is relevant from all my code.

        Basically, I'm using Annotations on Doctrine ORM, and am integrating with Gedmo for several of their extensions.

        I can run the CLI tool and update the schema, but when running via my web server, I'm getting the following error:

        {code}
        object(Doctrine\Common\Annotations\AnnotationException)[150]
          protected 'message' => string '[Semantical Error] The annotation "@Entity" in class Innertube\Models\Device was never imported. Did you maybe forget to add a "use" statement for this annotation?' (length=163)
          private 'string' (Exception) => string '' (length=0)
          protected 'code' => int 0
          protected 'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php' (length=211)
          protected 'line' => int 52
          private 'trace' (Exception) =>
            array
              0 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 592
                  'function' => string 'semanticalError' (length=15)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationException' (length=47)
                  'type' => string '::' (length=2)
                  'args' =>
                    array
                      ...
              1 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 533
                  'function' => string 'Annotation' (length=10)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              2 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 297
                  'function' => string 'Annotations' (length=11)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              3 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php' (length=208)
                  'line' => int 151
                  'function' => string 'parse' (length=5)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              4 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php' (length=204)
                  'line' => int 86
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              5 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php' (length=205)
                  'line' => int 61
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\CachedReader' (length=40)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              6 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=202)
                  'line' => int 112
                  'function' => string 'loadMetadataForClass' (length=20)
                  'class' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              7 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 302
                  'function' => string 'doLoadMetadata' (length=14)
                  'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              8 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 205
                  'function' => string 'loadMetadata' (length=12)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              9 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 268
                  'function' => string 'getMetadataFor' (length=14)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              10 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 682
                  'function' => string 'getClassMetadata' (length=16)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              11 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/api/routes/devices.php' (length=108)
                  'line' => int 16
                  'function' => string 'getRepository' (length=13)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
        {code}

        The call that initiates this is getRepository(), which IS NOT in the CLI.

        I've tracked it down to the fact that DocParser is not getting the list of names to ignore.

        Oddly, it gets it the first time that it's called by AnnotationReader. However, DocParser->parse() calls $this->Annotations(), which calls $this->Annotation(), calls $this->collectAnnotationMetadata(), which then creates a new parser (self::$metadataParser = new self();) and eventually parses it (self::$metadataParser->parse()), but DOES NOT pass its ignorednames.

        This seems like an oversight, but it clearly works for a lot of people. My configuration code is:

        {code}
                        if (self::$isDevMode) {
        $cache = new \Doctrine\Common\Cache\ArrayCache;
        } else {
        $cache = new \Doctrine\Common\Cache\ApcCache;
        }

        \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');

        AnnotationRegistry::registerFile(__DIR__ . "/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
        \Gedmo\DoctrineExtensions::registerAnnotations();



        $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
        $cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);



        $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, self::$namespaceArray);

        $config = new \Doctrine\ORM\Configuration;
        $config->setProxyNamespace('Proxy');
        $config->setAutoGenerateProxyClasses(self::$isDevMode); // this can be based on production config.
        // register metadata driver
        $config->setMetadataDriverImpl($annotationDriver);
        // use our allready initialized cache driver
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);

        if (defined('DIR_FILES_CACHE')) {
        $config->setProxyDir(DIR_FILES_CACHE);
        } else {
        $config->setProxyDir(sys_get_temp_dir());
        }

        // create event manager and hook prefered extension listeners
        $evm = new \Doctrine\Common\EventManager();

        $prefix = new TablePrefix(null);
        $prefix->useNamespace(true);
        $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefix);


        $blameableListener = new \Gedmo\Blameable\BlameableListener();
        $blameableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        //class_exists makes this usable with the command-line
        if (class_exists('\User') && ($u = new \User()) != false) {
        $blameableListener->setUserValue($u->getUserID());
        }
        $evm->addEventSubscriber($blameableListener);


        $timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
        $timestampableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        $evm->addEventSubscriber($timestampableListener);

        $config->addFilter('soft-deleteable', '\Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');


        return EntityManager::create($connectionOptions, $config, $evm);
        {code}

        and the entity is (which sets up the repository) is:

        {code}
        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\Mapping as ORM;
        use Doctrine\Common\Collections\ArrayCollection;
        use Gedmo\Mapping\Annotation as Gedmo;

        /**
         * @ORM\Entity(repositoryClass="DeviceRepository") @ORM\Table(name="Devices")
         * @Gedmo\SoftDeleteable(fieldName="deletedOn")
         **/
        class Device {
        {code}
        and the repository is:

        {code}
        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\EntityRepository;

        class DeviceRepository extends EntityRepository {
        {code}
        Marco Pivetta made changes -
        Description I'm just starting out with Doctrine, so my setup is a bit messy, but hopefully someone can figure out what is relevant from all my code.

        Basically, I'm using Annotations on Doctrine ORM, and am integrating with Gedmo for several of their extensions.

        I can run the CLI tool and update the schema, but when running via my web server, I'm getting the following error:

        {code}
        object(Doctrine\Common\Annotations\AnnotationException)[150]
          protected 'message' => string '[Semantical Error] The annotation "@Entity" in class Innertube\Models\Device was never imported. Did you maybe forget to add a "use" statement for this annotation?' (length=163)
          private 'string' (Exception) => string '' (length=0)
          protected 'code' => int 0
          protected 'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php' (length=211)
          protected 'line' => int 52
          private 'trace' (Exception) =>
            array
              0 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 592
                  'function' => string 'semanticalError' (length=15)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationException' (length=47)
                  'type' => string '::' (length=2)
                  'args' =>
                    array
                      ...
              1 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 533
                  'function' => string 'Annotation' (length=10)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              2 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 297
                  'function' => string 'Annotations' (length=11)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              3 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php' (length=208)
                  'line' => int 151
                  'function' => string 'parse' (length=5)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              4 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php' (length=204)
                  'line' => int 86
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              5 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php' (length=205)
                  'line' => int 61
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\CachedReader' (length=40)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              6 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=202)
                  'line' => int 112
                  'function' => string 'loadMetadataForClass' (length=20)
                  'class' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              7 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 302
                  'function' => string 'doLoadMetadata' (length=14)
                  'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              8 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 205
                  'function' => string 'loadMetadata' (length=12)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              9 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 268
                  'function' => string 'getMetadataFor' (length=14)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              10 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 682
                  'function' => string 'getClassMetadata' (length=16)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              11 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/api/routes/devices.php' (length=108)
                  'line' => int 16
                  'function' => string 'getRepository' (length=13)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
        {code}

        The call that initiates this is getRepository(), which IS NOT in the CLI.

        I've tracked it down to the fact that DocParser is not getting the list of names to ignore.

        Oddly, it gets it the first time that it's called by AnnotationReader. However, DocParser->parse() calls $this->Annotations(), which calls $this->Annotation(), calls $this->collectAnnotationMetadata(), which then creates a new parser (self::$metadataParser = new self();) and eventually parses it (self::$metadataParser->parse()), but DOES NOT pass its ignorednames.

        This seems like an oversight, but it clearly works for a lot of people. My configuration code is:

        {code}
                        if (self::$isDevMode) {
        $cache = new \Doctrine\Common\Cache\ArrayCache;
        } else {
        $cache = new \Doctrine\Common\Cache\ApcCache;
        }

        \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');

        AnnotationRegistry::registerFile(__DIR__ . "/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
        \Gedmo\DoctrineExtensions::registerAnnotations();



        $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
        $cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);



        $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, self::$namespaceArray);

        $config = new \Doctrine\ORM\Configuration;
        $config->setProxyNamespace('Proxy');
        $config->setAutoGenerateProxyClasses(self::$isDevMode); // this can be based on production config.
        // register metadata driver
        $config->setMetadataDriverImpl($annotationDriver);
        // use our allready initialized cache driver
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);

        if (defined('DIR_FILES_CACHE')) {
        $config->setProxyDir(DIR_FILES_CACHE);
        } else {
        $config->setProxyDir(sys_get_temp_dir());
        }

        // create event manager and hook prefered extension listeners
        $evm = new \Doctrine\Common\EventManager();

        $prefix = new TablePrefix(null);
        $prefix->useNamespace(true);
        $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefix);


        $blameableListener = new \Gedmo\Blameable\BlameableListener();
        $blameableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        //class_exists makes this usable with the command-line
        if (class_exists('\User') && ($u = new \User()) != false) {
        $blameableListener->setUserValue($u->getUserID());
        }
        $evm->addEventSubscriber($blameableListener);


        $timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
        $timestampableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        $evm->addEventSubscriber($timestampableListener);

        $config->addFilter('soft-deleteable', '\Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');


        return EntityManager::create($connectionOptions, $config, $evm);
        {code}

        and the entity is (which sets up the repository) is:

        {code}
        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\Mapping as ORM;
        use Doctrine\Common\Collections\ArrayCollection;
        use Gedmo\Mapping\Annotation as Gedmo;

        /**
         * @ORM\Entity(repositoryClass="DeviceRepository") @ORM\Table(name="Devices")
         * @Gedmo\SoftDeleteable(fieldName="deletedOn")
         **/
        class Device {
        {code}
        and the repository is:

        {code}
        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\EntityRepository;

        class DeviceRepository extends EntityRepository {
        {code}
        I'm just starting out with Doctrine, so my setup is a bit messy, but hopefully someone can figure out what is relevant from all my code.

        Basically, I'm using Annotations on Doctrine ORM, and am integrating with Gedmo for several of their extensions.

        I can run the CLI tool and update the schema, but when running via my web server, I'm getting the following error:

        {code}
        object(Doctrine\Common\Annotations\AnnotationException)[150]
          protected 'message' => string '[Semantical Error] The annotation "@Entity" in class Innertube\Models\Device was never imported. Did you maybe forget to add a "use" statement for this annotation?' (length=163)
          private 'string' (Exception) => string '' (length=0)
          protected 'code' => int 0
          protected 'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationException.php' (length=211)
          protected 'line' => int 52
          private 'trace' (Exception) =>
            array
              0 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 592
                  'function' => string 'semanticalError' (length=15)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationException' (length=47)
                  'type' => string '::' (length=2)
                  'args' =>
                    array
                      ...
              1 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 533
                  'function' => string 'Annotation' (length=10)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              2 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php' (length=201)
                  'line' => int 297
                  'function' => string 'Annotations' (length=11)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              3 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php' (length=208)
                  'line' => int 151
                  'function' => string 'parse' (length=5)
                  'class' => string 'Doctrine\Common\Annotations\DocParser' (length=37)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              4 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Annotations/CachedReader.php' (length=204)
                  'line' => int 86
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              5 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php' (length=205)
                  'line' => int 61
                  'function' => string 'getClassAnnotations' (length=19)
                  'class' => string 'Doctrine\Common\Annotations\CachedReader' (length=40)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              6 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php' (length=202)
                  'line' => int 112
                  'function' => string 'loadMetadataForClass' (length=20)
                  'class' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              7 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 302
                  'function' => string 'doLoadMetadata' (length=14)
                  'class' => string 'Doctrine\ORM\Mapping\ClassMetadataFactory' (length=41)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              8 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php' (length=228)
                  'line' => int 205
                  'function' => string 'loadMetadata' (length=12)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              9 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 268
                  'function' => string 'getMetadataFor' (length=14)
                  'class' => string 'Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory' (length=64)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              10 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/libraries/lerteco_framework/libraries/vendor-composer/doctrine/orm/lib/Doctrine/ORM/EntityManager.php' (length=187)
                  'line' => int 682
                  'function' => string 'getClassMetadata' (length=16)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
                  'type' => string '->' (length=2)
                  'args' =>
                    array
                      ...
              11 =>
                array
                  'file' => string '/Users/jshannon/Documents/Work/Projects/InnerTube/Repo/web/packages/lerteco_innertube/api/routes/devices.php' (length=108)
                  'line' => int 16
                  'function' => string 'getRepository' (length=13)
                  'class' => string 'Doctrine\ORM\EntityManager' (length=26)
        {code}

        The call that initiates this is getRepository(), which IS NOT in the CLI.

        I've tracked it down to the fact that DocParser is not getting the list of names to ignore.

        Oddly, it gets it the first time that it's called by AnnotationReader. However, DocParser->parse() calls $this->Annotations(), which calls $this->Annotation(), calls $this->collectAnnotationMetadata(), which then creates a new parser
        {code}self::$metadataParser = new self();{code} and eventually parses it {code}self::$metadataParser->parse(){code}, but DOES NOT pass its ignorednames.

        This seems like an oversight, but it clearly works for a lot of people. My configuration code is:

        {code}
                        if (self::$isDevMode) {
        $cache = new \Doctrine\Common\Cache\ArrayCache;
        } else {
        $cache = new \Doctrine\Common\Cache\ApcCache;
        }

        \Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('package');

        AnnotationRegistry::registerFile(__DIR__ . "/vendor-composer/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
        \Gedmo\DoctrineExtensions::registerAnnotations();



        $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();
        $cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);



        $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, self::$namespaceArray);

        $config = new \Doctrine\ORM\Configuration;
        $config->setProxyNamespace('Proxy');
        $config->setAutoGenerateProxyClasses(self::$isDevMode); // this can be based on production config.
        // register metadata driver
        $config->setMetadataDriverImpl($annotationDriver);
        // use our allready initialized cache driver
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);

        if (defined('DIR_FILES_CACHE')) {
        $config->setProxyDir(DIR_FILES_CACHE);
        } else {
        $config->setProxyDir(sys_get_temp_dir());
        }

        // create event manager and hook prefered extension listeners
        $evm = new \Doctrine\Common\EventManager();

        $prefix = new TablePrefix(null);
        $prefix->useNamespace(true);
        $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefix);


        $blameableListener = new \Gedmo\Blameable\BlameableListener();
        $blameableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        //class_exists makes this usable with the command-line
        if (class_exists('\User') && ($u = new \User()) != false) {
        $blameableListener->setUserValue($u->getUserID());
        }
        $evm->addEventSubscriber($blameableListener);


        $timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
        $timestampableListener->setAnnotationReader($config->getMetadataDriverImpl()->getReader());
        $evm->addEventSubscriber($timestampableListener);

        $config->addFilter('soft-deleteable', '\Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');


        return EntityManager::create($connectionOptions, $config, $evm);
        {code}

        and the entity is (which sets up the repository) is:

        {code}
        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\Mapping as ORM;
        use Doctrine\Common\Collections\ArrayCollection;
        use Gedmo\Mapping\Annotation as Gedmo;

        /**
         * @ORM\Entity(repositoryClass="DeviceRepository") @ORM\Table(name="Devices")
         * @Gedmo\SoftDeleteable(fieldName="deletedOn")
         **/
        class Device {
        {code}
        and the repository is:

        {code}
        namespace Innertube\Models;
        defined('C5_EXECUTE') or die('Access Denied.');

        use Doctrine\ORM\EntityRepository;

        class DeviceRepository extends EntityRepository {
        {code}

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            James S
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: