extension listeners

@param \Doctrine\Common\Annotations\Reader $annotationReader
@param \Doctrine\ORM\Mapping\Driver\DriverChain $driverChain
@return \Doctrine\Common\EventManager
761823
protected function initExtensions(\Doctrine\Common\Annotations\Reader $annotationReader, DriverChain $driverChain)
    {
        // load superclass metadata mapping only, into driver chain
        // also registers Gedmo annotations.NOTE: you can personalize it
        \Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $annotationReader);

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

        $eventsConf = Application::getConfigManager()->loadForModule('Cmf\Db', 'eventListener');

        foreach ($eventsConf as $itemConf) {
            $className = $itemConf->class;
            $listener = new $className();
            $listener->setAnnotationReader($annotationReader);
            $evm->addEventSubscriber($listener);
        }

        return $evm;
    }
1354441
protected function getEndpointsInClasses(SimpleAnnotationReader $reader)
    {
        $endpoints = new EndpointCollection();

        foreach ($this->getClassesToScan() as $class) {
            $endpoints = $endpoints->merge($this->getEndpointsInClass(
                $class, new AnnotationSet($class, $reader)
            ));
        }

        return $endpoints;
    }
1024528
protected function getAnnotationReader()
    {
        if ($this->packageSupportsLegacyCore()) {
            $reader = $this->getLegacyAnnotationReader();
        } else {
            $reader = $this->getStandardAnnotationReader();
        }
        return $reader;
    }
949816
private function getMetadataDriver()
    {
        if (null === $this->driver) {
            $metadataDirs = $this->getMetadataDirs();

            $annotationDriver = new AnnotationDriver($this->reader);
            if (!empty($metadataDirs)) {
                $fileLocator = new FileLocator($metadataDirs);
                $ymlDriver = new YamlDriver($fileLocator);
                $this->driver = new DriverChain(array(
                    $ymlDriver,
                    $annotationDriver,
                ));

                $ymlDriver->setDriver($this->driver);
            }
            else {
                $this->driver = $annotationDriver;
            }
        }

        return $this->driver;
    }
101253
protected function registerReader()
    {
        // Give a Cached Reader when our
        // reader class needs
        // a ReaderContract.
        $this->app->when(AnnotationsReader::class)
                  ->needs(Reader::class)
                  ->give(function () {
                      return $this->createAndReturnCachedReader();
                  });
    }
1048529
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /* @var $options FormAnnotationBuilder */
        $options = $serviceLocator->get(FormAnnotationBuilder::class);

        $cache = $serviceLocator->has($options->getCache())
            ? $serviceLocator->get($options->getCache())
            : null;

        $builder = new AnnotationBuilder($cache);

        if ($serviceLocator->has('FormElementManager')) {
            $serviceLocator->get('FormElementManager')->injectFactory($builder);
        }

        foreach ($options->getAnnotations() as $annotation) {
            $builder->getAnnotationParser()->registerAnnotation($annotation);
        }

        $events = $builder->getEventManager();
        foreach ($options->getListeners() as $listener) {
            $listener = $serviceLocator->has($listener)
                ? $serviceLocator->get($listener)
                : new $listener();

            if (!$listener instanceof ListenerAggregateInterface) {
                throw new RuntimeException(sprintf(
                    'Invalid event listener (%s) provided',
                    get_class($listener)
                ));
            }

            $events->attach($listener);
        }

        if (null !== $options->getPreserveDefinedOrder()) {
            $builder->setPreserveDefinedOrder($options->getPreserveDefinedOrder());
        }

        return $builder;
    }
166869
@Override
    public PipelineEventReader<XMLEventReader, XMLEvent> getEventReader(
            HttpServletRequest request, HttpServletResponse response) {
        // Get the reader from the parent and add the attribute incorporating wrapper
        final PipelineEventReader<XMLEventReader, XMLEvent> cachingEventReader =
                this.wrappedComponent.getEventReader(request, response);
        final XMLEventReader eventReader =
                new AttributeIncorporatingXMLEventReader(
                        request, response, cachingEventReader.getEventReader());

        final Map<String, String> outputProperties = cachingEventReader.getOutputProperties();
        return new PipelineEventReaderImpl<XMLEventReader, XMLEvent>(eventReader, outputProperties);
    }
879828
public static function registerAll(MappingDriverChain $driverChain)
    {
        self::register($driverChain, array_merge(self::$abstract, self::$concrete));
    }
1360591
public static function readMethod( $method , $annotation = null ) {

		$ref = $method instanceof ReflectionMethod ? $method : new ReflectionMethod( $method[0] , $method[1] );

		return $annotation ? static::reader()->getMethodAnnotation( $ref , $annotation ) : static::reader()->getMethodAnnotations( $ref );

	}
1238478
private static function getAnnotationReader()
    {
        if (null === self::$annotationReader) {
            if (!\class_exists('\\Doctrine\\Common\\Annotations\\AnnotationReader') ||
                !\class_exists('\\Doctrine\\Common\\Annotations\\AnnotationRegistry')) {
                throw new \Exception('In order to use graphql annotation, you need to require doctrine annotations');
            }

            AnnotationRegistry::registerLoader('class_exists');
            self::$annotationReader = new AnnotationReader();
        }

        return self::$annotationReader;
    }
760370
protected function filter(CommonValueReader $valueReader, Annotation $annotation)
    {
        return $valueReader->asArray($annotation->getSeparator(CommonValueReader::ARRAY_SEPARATOR));
    }
1235459
public function transformToDriver($driver, Closure $callback = null, $class = null)
    {
        if ($callback) {
            $result = call_user_func($callback, $this->get($driver));

            return new CustomCacheProvider($result, $driver);
        }

        if (class_exists($class)) {
            $result = new $class;

            if ($result instanceof CacheProvider) {
                $result->configure();
                $result->setName($driver);

                return $result;
            }
        }

        throw new CouldNotExtend('Expected an instance of Cache or Doctrine\Common\Cache');
    }
66058
protected function filter(CommonValueReader $valueReader, Annotation $annotation)
    {
        return $valueReader->asInt(new NumberRange(
                $annotation->getMinValue(),
                $annotation->getMaxValue()
        ));
    }
174818
private function processContextReaders(ContainerBuilder $container)
    {
        $references = $this->processor->findAndSortTaggedServices($container, self::READER_TAG);
        $definition = $container->getDefinition(self::getEnvironmentReaderId());

        foreach ($references as $reference) {
            $definition->addMethodCall('registerContextReader', array($reference));
        }
    }
191257
protected function filter(CommonValueReader $valueReader, Annotation $annotation)
    {
        return $valueReader->asText(
                new StringLength(
                        $annotation->getMinLength(),
                        $annotation->getMaxLength()
                ),
                $this->allowedTags($annotation)
        );
    }
496214
public static function create($paths = array(), Reader $reader = null)
    {
        if ($reader == null) {
            $reader = new AnnotationReader();
        }

        return new self($reader, $paths);
    }
1229
public function build()
    {
        $annotationReader = $this->annotationReader;
        if (null === $annotationReader) {
            $annotationReader = new AnnotationReader();

            if (null !== $this->cacheDir) {
                $this->createDir($this->cacheDir . '/annotations');
                $annotationReader = new FileCacheReader($annotationReader, $this->cacheDir . '/annotations', $this->debug);
            }
        }

        $metadataDriver = $this->driverFactory->createDriver($this->metadataDirs, $annotationReader);
        $metadataFactory = new MetadataFactory($metadataDriver);

        $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);

        if (null !== $this->cacheDir) {
            $this->createDir($this->cacheDir . '/metadata');
            $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata'));
        }

        $schemaRegistry = new SchemaRegistry($this->schemaDirs);

        // TODO registry caching

        return new Manager($metadataFactory, $schemaRegistry);
    }