当前位置: 首页>>代码示例>>PHP>>正文


PHP Annotations\AnnotationRegistry类代码示例

本文整理汇总了PHP中Doctrine\Common\Annotations\AnnotationRegistry的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationRegistry类的具体用法?PHP AnnotationRegistry怎么用?PHP AnnotationRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AnnotationRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBasicClassAnnotations

 /**
  * @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);
 }
开发者ID:siad007,项目名称:php-weasel,代码行数:10,代码来源:JsonAnySetterTest.php

示例2: register

 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);
     });
 }
开发者ID:xesenix,项目名称:bdf2-library,代码行数:35,代码来源:ORMServiceProvider.php

示例3: getFakedApiResponse

 public function getFakedApiResponse($class)
 {
     AnnotationRegistry::registerLoader('class_exists');
     $serializer = SerializerBuilder::create()->build();
     $response = new $class();
     return $serializer->serialize($response, 'json');
 }
开发者ID:Ticketpark,项目名称:SaferpayJsonApi,代码行数:7,代码来源:DeleteRequestTest.php

示例4: createService

 /**
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return object
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $manifest = $serviceLocator->get('manifest');
     $config = new Configuration();
     $config->setProxyDir(__DIR__ . '/../../../../Proxies');
     $config->setProxyNamespace('Proxies');
     $config->setHydratorDir(__DIR__ . '/../../../../Hydrators');
     $config->setHydratorNamespace('Hydrators');
     $config->setDefaultDB(self::DEFAULT_DB);
     $config->setMetadataCacheImpl(new ArrayCache());
     //create driver chain
     $chain = new MappingDriverChain();
     foreach ($manifest['documents'] as $namespace => $path) {
         $driver = new AnnotationDriver(new AnnotationReader(), $path);
         $chain->addDriver($driver, $namespace);
     }
     $config->setMetadataDriverImpl($chain);
     //register filters
     foreach ($manifest['filters'] as $name => $class) {
         $config->addFilter($name, $class);
     }
     //create event manager
     $eventManager = new EventManager();
     foreach ($manifest['subscribers'] as $subscriber) {
         $eventManager->addEventSubscriber($serviceLocator->get($subscriber));
     }
     //register annotations
     AnnotationRegistry::registerLoader(function ($className) {
         return class_exists($className);
     });
     $conn = new Connection(null, array(), $config);
     return DocumentManager::create($conn, $config, $eventManager);
 }
开发者ID:superdweebie,项目名称:doctrine-extensions,代码行数:38,代码来源:DocumentManagerFactory.php

示例5: setUp

 public function setUp()
 {
     AnnotationRegistry::registerAutoloadNamespace('Matmar10\\Bundle\\RestApiBundle\\Annotation', __DIR__ . '/../../../../../src');
     $container = $this->getKernel()->getContainer();
     $annotationReader = $container->get('annotation_reader');
     $this->controllerAnnotationReader = new ControllerAnnotationReader($annotationReader);
 }
开发者ID:matmar10,项目名称:rest-api-bundle,代码行数:7,代码来源:ControllerAnnotationReaderTest.php

示例6: __invoke

 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));
 }
开发者ID:mobicms,项目名称:expressive-doctrine,代码行数:25,代码来源:OrmFactory.php

示例7: __construct

 /**
  * @param string $userId
  * @param string $userPassword
  * @param int    $partnerId
  * @param string $partnerPassword
  * @param string $errorLanguage
  */
 public function __construct($userId, $userPassword, $partnerId, $partnerPassword, $errorLanguage)
 {
     AnnotationRegistry::registerLoader('class_exists');
     $this->afterbuyGlobal = new AfterbuyGlobal($userId, $userPassword, $partnerId, $partnerPassword, $errorLanguage);
     $this->client = new \GuzzleHttp\Client(['base_uri' => 'https://api.afterbuy.de/afterbuy/ABInterface.aspx']);
     $this->serializer = Client::getDefaultSerializer();
 }
开发者ID:asgoodasnu,项目名称:afterbuyapi,代码行数:14,代码来源:Client.php

示例8: setUp

 public function setUp()
 {
     $loader = (require __DIR__ . '/../vendor/autoload.php');
     AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
     $reader = new AnnotationReader();
     $this->annotClassLoader = new RouteAnnotationClassLoader($reader);
 }
开发者ID:wdalmut,项目名称:frankie,代码行数:7,代码来源:RouteAnnotationTest.php

示例9: factory

 /**
  * @param array $settings
  * @param bool $debug
  * @return EntityManager
  * @throws \Doctrine\ORM\ORMException
  */
 public static function factory($settings, $debug = true)
 {
     if ($debug || !function_exists('apc_fetch')) {
         $cache = new ArrayCache();
     } else {
         $cache = new ApcCache();
     }
     $dbSettings = $settings['doctrine'];
     $config = new Configuration();
     $config->setMetadataCacheImpl($cache);
     // Do not use default Annotation driver
     $driverImpl = new AnnotationDriver(new AnnotationReader(), $dbSettings['entities']);
     // Allow all annotations
     AnnotationRegistry::registerLoader('class_exists');
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir($dbSettings['proxy_path']);
     $config->setProxyNamespace('Zaralab\\Doctrine\\Proxies');
     if ($debug) {
         $config->setAutoGenerateProxyClasses(true);
     } else {
         $config->setAutoGenerateProxyClasses(false);
     }
     $connectionOptions = $dbSettings['dbal'];
     return EntityManager::create($connectionOptions, $config);
 }
开发者ID:myovchev,项目名称:zaralab-api,代码行数:32,代码来源:Doctrine.php

示例10: configure

 /**
  * {@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());
 }
开发者ID:kumamidori,项目名称:Ray.CakeDbModule,代码行数:10,代码来源:CakeDbModule.php

示例11: register

 /**
  * 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));
     });
 }
开发者ID:lrezek,项目名称:arachnid4laravel,代码行数:35,代码来源:ArachnidServiceProvider.php

示例12: __construct

 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);
 }
开发者ID:graphaware,项目名称:neo4j-php-ogm,代码行数:7,代码来源:AnnotationDriver.php

示例13: __construct

 public function __construct()
 {
     // load database configuration from CodeIgniter
     require_once APPPATH . 'config/database.php';
     $doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
     $doctrineClassLoader->register();
     $entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
     $entitiesClassLoader->register();
     $proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
     $proxiesClassLoader->register();
     // Set up caches
     $config = new Configuration();
     $cache = new ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $reader = new AnnotationReader();
     $driverImpl = new AnnotationDriver($reader, array(APPPATH . "models/Entities"));
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     // Proxy configuration
     $config->setProxyDir(APPPATH . '/models/proxies');
     $config->setProxyNamespace('Proxies');
     $config->setAutoGenerateProxyClasses(true);
     AnnotationRegistry::registerLoader('class_exists');
     // Database connection information
     $connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
     // Create EntityManager
     $this->em = EntityManager::create($connectionOptions, $config);
 }
开发者ID:richwandell,项目名称:Codeigniter-Example-App,代码行数:28,代码来源:Doctrine.php

示例14: setUp

 protected function setUp()
 {
     $pathToEntities = [__DIR__ . '/Entity'];
     $isDevMode = true;
     $connectionParams = array('user' => 'user', 'password' => 'password', 'driver' => 'pdo_sqlite', 'memory' => true);
     $config = Setup::createConfiguration($isDevMode);
     $driver = new AnnotationDriver(new AnnotationReader(), $pathToEntities);
     AnnotationRegistry::registerLoader('class_exists');
     $config->setMetadataDriverImpl($driver);
     $this->em = EntityManager::create($connectionParams, $config);
     /*
      * Устанавливаем фикстуры, знаю что можно это сделать более универсально, но ... в данном контексте мне больше и не надо
      */
     $conn = $this->em->getConnection();
     $conn->exec("CREATE TABLE clients (id INTEGER PRIMARY KEY, name TEXT, surname TEXT);");
     $conn->exec("CREATE TABLE authors (id INTEGER PRIMARY KEY, name TEXT, surname TEXT);");
     $conn->exec("CREATE TABLE books (id INTEGER, owner_id INTEGER, name TEXT, surname TEXT, CONSTRAINT 'pk' PRIMARY KEY (id, owner_id));");
     $conn->exec("INSERT INTO clients (name,surname) VALUES('Nikita','Sapogov')");
     $conn->exec("INSERT INTO clients (name,surname) VALUES('Alex','Ivanov')");
     $conn->exec("INSERT INTO clients (name,surname) VALUES('Sura','Soir')");
     $conn->exec("INSERT INTO clients (name,surname) VALUES('Vasya','Poliakocv')");
     $conn->exec("INSERT INTO books (id, owner_id, name) VALUES (1,1,'SuperBookNAme')");
     $conn->exec("INSERT INTO books (id, owner_id, name) VALUES (2,15,'SuperBookNAme2')");
     $conn->exec("INSERT INTO books (id, owner_id, name) VALUES (3,3,'SuperBookNAme3')");
 }
开发者ID:amstaffix,项目名称:common-doctrine-orm,代码行数:25,代码来源:TestCase.php

示例15: register

 public function register(Application $app)
 {
     //Load Doctrine Configuration
     $app['db.configuration'] = $app->share(function () use($app) {
         AnnotationRegistry::registerAutoloadNamespace("Doctrine\\ORM\\Mapping", __DIR__ . '/../../../../../doctrine/orm/lib');
         $config = new ORMConfiguration();
         $cache = $app['debug'] == false ? new ApcCache() : new ArrayCache();
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         $chain = new DriverChain();
         foreach ((array) $app['db.orm.entities'] as $entity) {
             switch ($entity['type']) {
                 case 'annotation':
                     $reader = new AnnotationReader();
                     $driver = new AnnotationDriver($reader, (array) $entity['path']);
                     $chain->addDriver($driver, $entity['namespace']);
                     break;
                     /*case 'yml':
                           $driver = new YamlDriver((array)$entity['path']);
                           $driver->setFileExtension('.yml');
                           $chain->addDriver($driver, $entity['namespace']);
                           break;
                       case 'xml':
                           $driver = new XmlDriver((array)$entity['path'], $entity['namespace']);
                           $driver->setFileExtension('.xml');
                           $chain->addDriver($driver, $entity['namespace']);
                           break;*/
                 /*case 'yml':
                       $driver = new YamlDriver((array)$entity['path']);
                       $driver->setFileExtension('.yml');
                       $chain->addDriver($driver, $entity['namespace']);
                       break;
                   case 'xml':
                       $driver = new XmlDriver((array)$entity['path'], $entity['namespace']);
                       $driver->setFileExtension('.xml');
                       $chain->addDriver($driver, $entity['namespace']);
                       break;*/
                 default:
                     throw new \InvalidArgumentException(sprintf('"%s" is not a recognized driver', $type));
                     break;
             }
         }
         $config->setMetadataDriverImpl($chain);
         $config->setProxyDir($app['db.orm.proxies_dir']);
         $config->setProxyNamespace($app['db.orm.proxies_namespace']);
         $config->setAutoGenerateProxyClasses($app['db.orm.auto_generate_proxies']);
         return $config;
     });
     //Set Defaut Configuration
     $defaults = array('entities' => array(array('type' => 'annotation', 'path' => 'Entity', 'namespace' => 'Entity')), 'proxies_dir' => 'cache/doctrine/Proxy', 'proxies_namespace' => 'DoctrineProxy', 'auto_generate_proxies' => true);
     foreach ($defaults as $key => $value) {
         if (!isset($app['db.orm.' . $key])) {
             $app['db.orm.' . $key] = $value;
         }
     }
     $self = $this;
     $app['db.orm.em'] = $app->share(function () use($self, $app) {
         return EntityManager::create($app['db'], $app['db.configuration']);
     });
 }
开发者ID:amenophis,项目名称:silex-doctrineorm,代码行数:60,代码来源:DoctrineORMServiceProvider.php


注:本文中的Doctrine\Common\Annotations\AnnotationRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。