/** * * @param string $class * @param array $config * @return ClassAnnotationHolder */ public function parse($class, array $config = array()) { $annotationManager = new AnnotationManager(); $parser = new DoctrineAnnotationParser(); $parser->registerAnnotation(Route::class); $parser->registerAnnotation(Service::class); $parser->registerAnnotation(Controller::class); $parser->registerAnnotation(ControllerPlugin::class); $parser->registerAnnotation(Filter::class); $parser->registerAnnotation(FormElement::class); $parser->registerAnnotation(Hydrator::class); $parser->registerAnnotation(InputFilter::class); $parser->registerAnnotation(LogProcessor::class); $parser->registerAnnotation(LogWriter::class); $parser->registerAnnotation(Route::class); $parser->registerAnnotation(RoutePlugin::class); $parser->registerAnnotation(Serializer::class); $parser->registerAnnotation(Validator::class); $parser->registerAnnotation(ViewHelper::class); $annotationManager->attach($parser); $scanner = new DirectoryScanner('.'); $class = $scanner->getClass($class); $eventManager = new EventManager(); $parser = new ClassParser($config, $annotationManager, $eventManager); return $this->handleClassAnnotations($parser->parseClass($class), $config); }
/** * Create default annotation manager * * @return AnnotationManager */ public function createDefaultAnnotationManager() { $annotationManager = new AnnotationManager(); $parser = new GenericAnnotationParser(); $parser->registerAnnotation(new Annotation\Inject()); $annotationManager->attach($parser); return $annotationManager; }
/** * @param ServiceLocatorInterface $serviceLocator * @return AnnotationManager */ public function createService(ServiceLocatorInterface $serviceLocator) { $annotationManager = new AnnotationManager(); $parser = new DoctrineAnnotationParser(); $parser->registerAnnotation('AnnotatedRouter\\Annotation\\Route'); $annotationManager->attach($parser); return $annotationManager; }
/** * Set annotation manager to use when building form from annotations * * @param AnnotationManager $annotationManager * @return AnnotationBuilder */ public function setAnnotationManager(AnnotationManager $annotationManager) { $parser = new Parser\DoctrineAnnotationParser(); foreach ($this->defaultAnnotations as $annotationName) { $class = __NAMESPACE__ . '\\' . $annotationName; $parser->registerAnnotation($class); } $annotationManager->attach($parser); $this->annotationManager = $annotationManager; return $this; }
public function testScannerWorks() { $annotationManager = new AnnotationManager(); $parser = new GenericAnnotationParser(); $parser->registerAnnotations(array($foo = new TestAsset\Annotation\Foo(), $bar = new TestAsset\Annotation\Bar())); $annotationManager->attach($parser); $docComment = '/**' . "\n" . ' * @Test\\Foo(\'anything I want()' . "\n" . ' * to be\')' . "\n" . ' * @Test\\Bar' . "\n */"; $nameInfo = new NameInformation(); $nameInfo->addUse('ZendTest\\Code\\Scanner\\TestAsset\\Annotation', 'Test'); $annotationScanner = new AnnotationScanner($annotationManager, $docComment, $nameInfo); $this->assertEquals(get_class($foo), get_class($annotationScanner[0])); $this->assertEquals("'anything I want()\n to be'", $annotationScanner[0]->getContent()); $this->assertEquals(get_class($bar), get_class($annotationScanner[1])); }
public function testAnnotationScanningIsPossible() { $manager = new AnnotationManager(); $parser = new GenericAnnotationParser(); $parser->registerAnnotation(new TestAsset\SampleAnnotation()); $manager->attach($parser); $property = new \Zend\Code\Reflection\PropertyReflection('ZendTest\\Code\\Reflection\\TestAsset\\TestSampleClass2', '_prop2'); $annotations = $property->getAnnotations($manager); $this->assertInstanceOf('Zend\\Code\\Annotation\\AnnotationCollection', $annotations); $this->assertTrue($annotations->hasAnnotation('ZendTest\\Code\\Reflection\\TestAsset\\SampleAnnotation')); $found = false; foreach ($annotations as $key => $annotation) { if (!$annotation instanceof TestAsset\SampleAnnotation) { continue; } $this->assertEquals(get_class($annotation) . ': {"foo":"bar"}', $annotation->content); $found = true; break; } $this->assertTrue($found); }
public function getServiceConfig() { return array('factories' => array('zf2clientmoysklad_module_options' => function ($sm) { $config = $sm->get('config'); return new ModuleOptions(isset($config['zf2clientmoysklad']) ? $config['zf2clientmoysklad'] : array()); }, 'zf2clientmoysklad_metadata_collection' => function () { $directoryScanner = new DirectoryScanner(__DIR__ . '/src/Zf2ClientMoysklad/Entity'); $annotationManager = new AnnotationManager(); $annotationManager->attach(new AnnotationParser()); $collector = new EntityCollector($annotationManager, $directoryScanner); return new MetadataCollection($collector); }, 'zf2clientmoysklad_entity_manager' => function ($sm) { $mapper = new GenericMapper($sm->get('zf2clientmoysklad_generic_transport')); $metadataCollection = $sm->get('zf2clientmoysklad_metadata_collection'); return new EntityManager(new UnitOfWork($metadataCollection, $mapper), $metadataCollection); }, 'zf2clientmoysklad_generic_transport' => function ($sm) { $client = new \Zend\Http\Client(); $options = $sm->get('zf2clientmoysklad_module_options'); return new GenericTransport($options, $client); })); }
/** * * @param array $annotations * @return AnnotationManager */ public static function factory(array $annotations) { $manager = new AnnotationManager(); $manager->attach(DoctrineAnnotationParserFactory::factory($annotations)); return $manager; }
use KJSencha\Direct\DirectManager; use KJSencha\Service\TestEchoService; use KJSencha\Frontend\Bootstrap; use Zend\Cache\StorageFactory; use Zend\Code\Annotation\AnnotationManager; use Zend\Code\Annotation\Parser\DoctrineAnnotationParser; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceManager; return array('factories' => array('kjsencha.api' => 'KJSencha\\Service\\ApiFactory', 'kjsencha.componentmanager' => 'KJSencha\\Service\\ComponentManagerFactory', 'kjsencha.annotationmanager' => function () { $doctrineParser = new DoctrineAnnotationParser(); $doctrineParser->registerAnnotation('KJSencha\\Annotation\\Remotable'); $doctrineParser->registerAnnotation('KJSencha\\Annotation\\Interval'); $doctrineParser->registerAnnotation('KJSencha\\Annotation\\Formhandler'); $doctrineParser->registerAnnotation('KJSencha\\Annotation\\Group'); $annotationManager = new AnnotationManager(); $annotationManager->attach($doctrineParser); return $annotationManager; }, 'kjsencha.apibuilder' => function (ServiceLocatorInterface $sl) { /* @var $annotationManager AnnotationManager */ $annotationManager = $sl->get('kjsencha.annotationmanager'); /* @var $directManager DirectManager */ $directManager = $sl->get('kjsencha.direct.manager'); return new ApiBuilder($annotationManager, $directManager); }, 'kjsencha.cache' => function (ServiceLocatorInterface $sl) { $config = $sl->get('Config'); $storage = StorageFactory::factory($config['kjsencha']['cache']); return $storage; }, 'kjsencha.bootstrap' => function (ServiceLocatorInterface $sl) { $config = $sl->get('Config'); $bootstrap = new Bootstrap($config['kjsencha']['bootstrap']['default']); $bootstrap->addVariables(array('App' => array('basePath' => $sl->get('Request')->getBasePath())));