private function registerAnnotationFile() { $dir = __DIR__ . self::DS . '..' . self::DS . '..' . self::DS . self::ANNOTATION_NS . self::DS; foreach (glob($dir . self::PHP) as $filename) { AnnotationRegistry::registerFile($filename); } }
public function __construct(ClassMultiMap $classMap, AnnotationReader $annotationReader, PhpParser $phpParser) { $this->classMap = $classMap; $this->annotationReader = $annotationReader; $this->phpParser = $phpParser; AnnotationRegistry::registerFile(__DIR__ . "/../../Annotation/Autowired.php"); }
public function __construct() { // load database configuration from CodeIgniter require_once APPPATH . 'config/database.php'; //A Doctrine Autoloader is needed to load the models $entitiesClassLoader = new ClassLoader('Entity', APPPATH . "models"); $entitiesClassLoader->register(); // Set up caches $config = new Configuration(); $cache = new ArrayCache(); $config->setMetadataCacheImpl($cache); AnnotationRegistry::registerFile(APPPATH . "vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); $reader = new AnnotationReader(); $driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(APPPATH . 'models/Entity')); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setQueryCacheImpl($cache); // Proxy configuration $config->setProxyDir(APPPATH . 'models/proxies'); $config->setProxyNamespace('Proxies'); // Set up logger // $logger = new EchoSQLLogger; // $config->setSQLLogger($logger); $config->setAutoGenerateProxyClasses(TRUE); // Database connection information $connectionOptions = array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => 'whoami', 'host' => 'localhost', 'dbname' => 'pms3'); // Create EntityManager $this->em = EntityManager::create($connectionOptions, $config); }
public function __construct(Reader $reader = null) { AnnotationRegistry::registerFile(__DIR__ . '/Annotations/PluginAnnotations.php'); if ($reader) { $this->setAnnotationReader($reader); } }
/** * @param array $paths * @return \Doctrine\ORM\Mapping\Driver\AnnotationDriver */ protected function createAnnotationDriver($paths = array(), $alias = null) { if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0', '>=')) { $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\AnnotationReader(), new ArrayCache()); } else { if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) { // Register the ORM Annotations in the AnnotationRegistry $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Doctrine\\ORM\\Mapping'); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache()); } else { if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) { $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader->setIgnoreNotImportedAnnotations(true); $reader->setEnableParsePhpImports(false); if ($alias) { $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias); } else { $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\'); } $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache()); } else { $reader = new \Doctrine\Common\Annotations\AnnotationReader(); if ($alias) { $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias); } else { $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\'); } } } } \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../../../lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths); }
protected function setUp() { // Register the DREST annotations \Drest\Mapping\Driver\AnnotationDriver::registerAnnotations(); // Register the ORM annotations \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); }
function createDoctrineConfig($cache, $cachedAnnotationReader) { AnnotationRegistry::registerFile(dirname(__DIR__) . "/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); //$cache = new Doctrine\Common\Cache\ArrayCache; // if (extension_loaded('apc')) { // $cache = new \Doctrine\Common\Cache\ApcCache(); // } else { // $cache = new \Doctrine\Common\Cache\PhpFileCache(); // } $isDevMode = true; // $annotationReader = new AnnotationReader; // $cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader( // $annotationReader, // use reader // $cache // and a cache driver // ); $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, array(__DIR__ . '/Resource')); $driverChain = new Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain(); Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $cachedAnnotationReader); $driverChain->addDriver($annotationDriver, 'Uppu4\\Entity'); $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Resource"), $isDevMode); //!!!!!! $config = new Doctrine\ORM\Configuration(); $config->setProxyDir(sys_get_temp_dir()); $config->setProxyNamespace('Proxy'); $config->setAutoGenerateProxyClasses(true); // this can be based on production config. // register metadata driver $config->setMetadataDriverImpl($driverChain); // use our already initialized cache driver $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $deleted = $cache->deleteAll(); return $config; }
public function newDefaultAnnotationDriver($paths = array()) { \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php'); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache()); return new Core_Model_OWM_Mapping_Driver_AnnotationDriver($reader, (array) $paths); }
public static function loadAnnotations() { $reflClass = new \ReflectionClass(__CLASS__); $path = dirname($reflClass->getFileName()); AnnotationRegistry::registerFile($path . '/DataMapping/Annotations.php'); AnnotationRegistry::registerFile($path . '/Service/SortingFieldAnnotations.php'); }
/** * Registers services on the given app. * * This method should only be used to configure services and parameters. * It should not get services. * @param Application $app */ public function register(Application $app) { parent::register($app); $app->register(new \Silex\Provider\DoctrineServiceProvider(), ['db.options' => $app['config']['db.options']]); $app->register(new DoctrineOrmServiceProvider(), $app['config']['orm.options']); if (getenv('MIGRATION_COMMANDS')) { $app->register(new MigrationServiceProvider(), ['db.migrations.path' => $app['config']['migrations.directory']]); } $app['orm.em'] = $app->extend('orm.em', function (EntityManagerInterface $em) use($app) { if (file_exists(APP_PATH . '/vendor/apitude/apitude/src/Annotations/APIAnnotations.php')) { AnnotationRegistry::registerFile(APP_PATH . '/vendor/apitude/apitude/src/Annotations/APIAnnotations.php'); } /** @var Configuration $config */ $config = $em->getConfiguration(); $config->setMetadataCacheImpl($app['cache']); $config->addCustomHydrationMode('simple', SimpleHydrator::class); /** @var MappingDriverChain $driver */ $driver = $config->getMetadataDriverImpl(); // gedmo initialization $reader = new AnnotationReader(); $cache = new CachedReader($reader, $app['cache']); DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driver, $cache); return $em; }); }
/** * * @return \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain */ public function getMetadataDriverImpl() { // Register the doctrine Annotations \Doctrine\Common\Annotations\AnnotationRegistry::registerFile('doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); $legacyNamespace = $this->getConfigRepository()->get('app.enable_legacy_src_namespace'); if ($legacyNamespace) { \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Application\\Src', DIR_BASE . '/application/src'); } else { \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Application\\Entity', DIR_BASE . '/application/src/Entity'); } // Remove all unkown annotations from the AnnotationReader used by the SimpleAnnotationReader // to prevent fatal errors $this->registerGlobalIgnoredAnnotations(); // initiate the driver chain which will hold all driver instances $driverChain = $this->app->make('Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain'); $coreDriver = new CoreDriver($this->app); $driver = $coreDriver->getDriver(); $driver->addExcludePaths($this->getConfigRepository()->get('database.proxy_exclusions', array())); $driverChain->addDriver($driver, $coreDriver->getNamespace()); // Register application metadata driver $config = $this->getConfigRepository(); $applicationDriver = new ApplicationDriver($config, $this->app); $driver = $applicationDriver->getDriver(); if (is_object($driver)) { // $driver might be null, if there's no application/src/Entity $driverChain->addDriver($driver, $applicationDriver->getNamespace()); } return $driverChain; }
/** * Register the service provider. * * @return void */ public function register() { $app = $this->app; //Make and share the singleton with the application $app['lrezek.neo4laravel.entitymanager'] = $app->share(function ($app) { //Register annotations with doctrine \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Auto.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Entity.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Index.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/ManyToMany.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/ManyToOne.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/hirevoice/neo4jphp-ogm/lib/HireVoice/Neo4j/Annotation/Property.php'); //Get config parameters $connectionName = "neo4j"; $settings = $app['config']->get('database.connections'); $config = isset($settings[$connectionName]) ? $settings[$connectionName] : $settings; //If you have a meta cache but not a annotation reader, make a annotation reader out of the meta cache if (empty($config['annotation_reader']) && !empty($config['meta_data_cache'])) { //Get the associated doctrine class $metaCache = new $this->cacheMap[$config['meta_data_cache']](); //Set the namespace to the cache_prefix, or make it neo4j if it's not there $metaCache->setNamespace(empty($config['cache_prefix']) ? 'neo4j' : $config['cache_prefix']); //Create the reader $config['annotation_reader'] = new CachedReader(new AnnotationReader(), $metaCache, false); } //Return the new instance (the share method insures it's a singleton) return new EntityManager(new Configuration($config)); }); }
public function register(Application $app) { $app['orm.em.paths'] = $app->share(function () { return array(); }); $app['orm.event_manager'] = $app->share(function () use($app) { return new EventManager(); }); $app['orm.config'] = $app->share(function () use($app) { return Setup::createConfiguration($app['debug']); }); $app['orm.anotation_reader'] = $app->share(function () use($app) { $annotationReader = new AnnotationReader(); $cache = $app['orm.config']->getMetadataCacheImpl(); return new CachedReader($annotationReader, $cache); }); $app['orm.default_anotation_driver'] = $app->share(function () use($app) { AnnotationRegistry::registerFile($app['vendor_dir'] . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); return new AnnotationDriver($app['orm.anotation_reader'], $app['orm.em.paths']); }); $app['orm.em'] = $app->share(function () use($app) { $annotationReader = $app['orm.anotation_reader']; $eventManager = $app['orm.event_manager']; $driverChain = new MappingDriverChain(); $driverChain->setDefaultDriver($app['orm.default_anotation_driver']); DoctrineExtensions::registerMappingIntoDriverChainORM($driverChain, $annotationReader); $loggableListener = new LoggableListener(); $loggableListener->setAnnotationReader($annotationReader); $loggableListener->setUsername('admin'); $eventManager->addEventSubscriber($loggableListener); $config = $app['orm.config']; $config->setMetadataDriverImpl($driverChain); return EntityManager::create($app['db.default_options'], $config, $eventManager); }); }
/** * Create a new event scanner instance. * * @param array $scan * @return void */ public function __construct(array $scan) { $this->scan = $scan; foreach (Finder::create()->files()->in(__DIR__ . '/Annotations') as $file) { AnnotationRegistry::registerFile($file->getRealPath()); } }
/** * Register the service provider. * * @return void */ public function register() { $app = $this->app; //Make and share the singleton with the application $app['lrezek.arachnid4laravel.arachnid'] = $app->share(function ($app) { //Register annotations with doctrine \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/Auto.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/End.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/Index.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/Start.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/Node.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/Relation.php'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(app_path() . '/../vendor/lrezek/arachnid/src/LRezek/Arachnid/Annotation/Property.php'); //Get config parameters $default = $app['config']->get('database.default'); $settings = $app['config']->get('database.connections'); $config = !empty($default) && $default == 'neo4j' ? $settings[$default] : $settings; //If you have a meta cache but not a annotation reader, make a annotation reader out of the meta cache if (empty($config['annotation_reader']) && !empty($config['meta_data_cache'])) { //Get the associated doctrine class $metaCache = new $this->cacheMap[$config['meta_data_cache']](); //Set the namespace to the cache_prefix, or make it neo4j if it's not there $metaCache->setNamespace(empty($config['cache_prefix']) ? 'neo4j' : $config['cache_prefix']); //Create the reader $config['annotation_reader'] = new CachedReader(new AnnotationReader(), $metaCache, false); } //Return the new instance (the share method insures it's a singleton) return new Arachnid(new Configuration($config)); }); }
public function __invoke(ContainerInterface $container) { if (!$container->has(Configuration::class) || !$container->has(EventManager::class) || !$container->has(Connection::class)) { throw new ContainerNotRegisteredException('Doctrine\\Common\\EventManager::class, Doctrine\\ORM\\Configuration::class and Doctrine\\DBAL\\Connection::class must be registered in the container'); } $config = $container->has('config') ? $container->get('config') : []; $underscoreNamingStrategy = isset($config['doctrine']['orm']['underscore_naming_strategy']) ? $config['doctrine']['orm']['underscore_naming_strategy'] : false; /** @var Configuration $configuration */ $configuration = $container->get(Configuration::class); $configuration->setProxyDir(isset($config['doctrine']['orm']['proxy_dir']) ? $config['doctrine']['orm']['proxy_dir'] : 'data/cache/EntityProxy'); $configuration->setProxyNamespace(isset($config['doctrine']['orm']['proxy_namespace']) ? $config['doctrine']['orm']['proxy_namespace'] : 'EntityProxy'); $configuration->setAutoGenerateProxyClasses(isset($config['doctrine']['orm']['auto_generate_proxy_classes']) ? $config['doctrine']['orm']['auto_generate_proxy_classes'] : false); // ORM mapping by Annotation AnnotationRegistry::registerFile('vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); $driver = new AnnotationDriver(new AnnotationReader(), ['data/cache/doctrine']); $configuration->setMetadataDriverImpl($driver); // Cache $cache = $container->get(Cache::class); $configuration->setQueryCacheImpl($cache); $configuration->setResultCacheImpl($cache); $configuration->setMetadataCacheImpl($cache); return EntityManager::create($container->get(Connection::class), $configuration, $container->get(EventManager::class)); }
public function __construct($cacheDirectory = null) { $cacheDir = $cacheDirectory ?: sys_get_temp_dir(); AnnotationRegistry::registerFile(__DIR__ . '/Neo4jOGMAnnotations.php'); $reader = new AnnotationReader(); $this->reader = new FileCacheReader($reader, $cacheDir, $debug = true); }
/** * {@inheritdoc} */ protected function configure() { AnnotationRegistry::registerFile(__DIR__ . '/DoctrineAnnotations.php'); $this->bind()->annotatedWith('Ray\\CakeDbModule\\Annotation\\CakeDbConfig')->toInstance($this->config); $this->bind('Cake\\Database\\Connection')->toProvider('Ray\\CakeDbModule\\ConnectionProvider')->in(Scope::SINGLETON); $this->install(new TransactionalModule()); }
/** * @covers \Weasel\JsonMarshaller\Config\DoctrineAnnotations\JsonAnySetter */ public function testBasicClassAnnotations() { AnnotationRegistry::registerFile(__DIR__ . '/../../../../../lib/Weasel/JsonMarshaller/Config/DoctrineAnnotations/JsonAnySetter.php'); $annotationReader = new AnnotationReader(); $got = $annotationReader->getMethodAnnotations(new \ReflectionMethod(__NAMESPACE__ . '\\JsonAnySetterTestVictim', 'basic')); $this->assertEquals(array(new JsonAnySetter()), $got); }
/** * @param ContainerInterface $container * @return EntityManager */ public function __invoke(ContainerInterface $container) { $config = $container->has('config') ? $container->get('config') : []; if (!isset($config['doctrine'])) { throw new ServiceNotCreatedException('Missing Doctrine configuration'); } $config = $config['doctrine']; $proxyDir = isset($config['proxy_dir']) ? $config['proxy_dir'] : 'data/DoctrineORM/Proxy'; $proxyNamespace = isset($config['proxy_namespace']) ? $config['proxy_namespace'] : 'DoctrineORM/Proxy'; $autoGenerateProxyClasses = isset($config['configuration']['auto_generate_proxy_classes']) ? $config['configuration']['auto_generate_proxy_classes'] : false; $underscoreNamingStrategy = isset($config['configuration']['underscore_naming_strategy']) ? $config['configuration']['underscore_naming_strategy'] : false; // Doctrine ORM $doctrine = new Configuration(); $doctrine->setProxyDir($proxyDir); $doctrine->setProxyNamespace($proxyNamespace); $doctrine->setAutoGenerateProxyClasses($autoGenerateProxyClasses); // Naming Strategy if ($underscoreNamingStrategy) { $doctrine->setNamingStrategy(new UnderscoreNamingStrategy()); } // ORM mapping by Annotation //AnnotationRegistry::registerAutoloadNamespace($config['driver']['annotations']['class']); AnnotationRegistry::registerFile('vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); $driver = new AnnotationDriver(new AnnotationReader(), $config['driver']['annotations']['paths']); $doctrine->setMetadataDriverImpl($driver); // Cache $cache = $container->get(\Doctrine\Common\Cache\Cache::class); $doctrine->setQueryCacheImpl($cache); $doctrine->setResultCacheImpl($cache); $doctrine->setMetadataCacheImpl($cache); // EntityManager return EntityManager::create($config['connection']['orm_default']['params'], $doctrine); }
/** * @covers \Weasel\JsonMarshaller\Config\DoctrineAnnotations\JsonInclude */ public function testBasic() { AnnotationRegistry::registerFile(__DIR__ . '/../../../../../lib/Weasel/JsonMarshaller/Config/DoctrineAnnotations/JsonInclude.php'); $annotationReader = new AnnotationReader(); $got = $annotationReader->getClassAnnotation(new \ReflectionClass(__NAMESPACE__ . '\\JsonIncludeTestVictim'), __NAMESPACE__ . '\\JsonInclude'); $this->assertInstanceOf(__NAMESPACE__ . '\\JsonInclude', $got); $this->assertEquals(JsonInclude::INCLUDE_ALWAYS, $got->getValue()); }
/** * @return \Doctrine\ORM\EntityManager */ private function buildEntityManager() { AnnotationRegistry::registerFile(__DIR__ . '/../../Doctrine/Mapping/File.php'); $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/Fixtures'), false, \sys_get_temp_dir(), null, false); $config->setAutoGenerateProxyClasses(true); $params = array('driver' => 'pdo_sqlite', 'memory' => true); return EntityManager::create($params, $config); }
/** * A basic functional test example. * * @return Skimia\ApiFusion\Annotations\ApiRouting\Scanner */ public function registerAnnotations() { $scanner = new \Skimia\ApiFusion\Annotations\ApiRouting\Scanner($this->app, []); foreach (Finder::create()->files()->in(__DIR__ . '/fixtures/Annotations') as $file) { AnnotationRegistry::registerFile($file->getRealPath()); } return $scanner; }
protected function setUp() { $vendor_dir = isset($_ENV['VENDOR_DIR']) ? realpath(__DIR__ . '/' . $_ENV['VENDOR_DIR']) : realpath(__DIR__ . '/../../../../../../../symfony/vendor'); AnnotationRegistry::registerFile($vendor_dir . "/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); AnnotationRegistry::registerFile($vendor_dir . "/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Configuration/Route.php"); AnnotationRegistry::registerFile($vendor_dir . "/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Configuration/Method.php"); AnnotationRegistry::registerFile($vendor_dir . "/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/Configuration/Template.php"); }
public function setUp() { parent::setUp(); $mappingDir = getenv('basedir') . DIRECTORY_SEPARATOR . 'src/Mapping/'; AnnotationRegistry::registerFile($mappingDir . '/Neo4jOGMAnnotations.php'); $this->annotationReader = new FileCacheReader(new AnnotationReader(), getenv('proxydir'), true); $this->entityMetadataFactory = new GraphEntityMetadataFactory($this->annotationReader); }
/** * Register annotations when not yet done. */ public static function registerAnnotations() { // Check if we need to register the Annotations if (!self::$registered) { AnnotationRegistry::registerFile(__DIR__ . '/Structure/SweetAnnotations.php'); self::$registered = true; } }
public function testGetAllClassNames() { AnnotationRegistry::registerFile(__DIR__ . '/../../../Annotation/Resource.php'); $reader = new AnnotationReader(); $driver = new AnnotationDriver($reader, array('Conjecto\\Nemrod\\ResourceManager\\Tests\\Fixtures\\TestBundle' => __DIR__ . '/../../Fixtures/TestBundle/RdfResource')); $classes = $driver->getAllClassNames(); $this->assertEquals(array('Conjecto\\Nemrod\\ResourceManager\\Tests\\Fixtures\\TestBundle\\RdfResource\\TestResource'), $classes); }
/** * Constructor * * @param array $data Key-value for properties to be defined in this class */ public final function __construct(array $data) { foreach ($data as $key => $value) { $this->{$key} = $value; } AnnotationRegistry::registerFile(__DIR__ . '/Annotation/VarType.php'); $this->reader = new AnnotationReader(); }
/** * @covers \Weasel\JsonMarshaller\Config\DoctrineAnnotations\JsonCreator * @covers \Weasel\JsonMarshaller\Config\DoctrineAnnotations\JsonProperty */ public function testConstructorClassAnnotations() { AnnotationRegistry::registerFile(__DIR__ . '/../../../../../lib/Weasel/JsonMarshaller/Config/DoctrineAnnotations/JsonCreator.php'); AnnotationRegistry::registerFile(__DIR__ . '/../../../../../lib/Weasel/JsonMarshaller/Config/DoctrineAnnotations/JsonProperty.php'); $annotationReader = new AnnotationReader(); $got = $annotationReader->getMethodAnnotations(new \ReflectionMethod(__NAMESPACE__ . '\\JsonCreatorTestVictim', '__construct')); $this->assertEquals(array(new JsonCreator(array("params" => array(new JsonProperty(array("name" => "foo", "type" => "int")), new JsonProperty(array("name" => "bar", "type" => "int")))))), $got); }
/** * @return ClassMetadataFactory */ protected function getClassMetadataFactory() { $reader = new CachedReader(new AnnotationReader(), new FilesystemCache($this->cacheDirectory), $debug = true); AnnotationRegistry::registerFile(__DIR__ . '/../../Metadata/Annotations/Migratable.php'); $driver = new AnnotationDriver($reader, [__DIR__ . '/../Fixtures']); $driver->addExcludePaths([__DIR__ . '/../Fixtures/Event', __DIR__ . '/../Fixtures/Listener']); return new ClassMetadataFactory($driver); }