コード例 #1
1
 protected function setUp()
 {
     AnnotationRegistry::registerLoader('class_exists');
     $conn = DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'memory' => true));
     $this->em = $this->_getTestEntityManager($conn);
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Bazinga\\Bundle\\GeocoderBundle\\Mapping\\Annotations');
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $driver = new AnnotationDriver($reader);
     $geocoder = new GoogleMaps(new CurlHttpAdapter());
     $this->listener = new GeocoderListener($geocoder, $driver);
     $this->em->getEventManager()->addEventSubscriber($this->listener);
     $sm = new SchemaTool($this->em);
     $sm->createSchema(array($this->em->getClassMetadata('Bazinga\\Bundle\\GeocoderBundle\\Tests\\Doctrine\\ORM\\Dummy')));
 }
コード例 #2
0
 protected function getReader()
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace(__NAMESPACE__);
     $reader->addNamespace(__NAMESPACE__ . '\\Fixtures');
     $reader->addNamespace(__NAMESPACE__ . '\\Fixtures\\Annotation');
     return $reader;
 }
コード例 #3
0
ファイル: Blueprint.php プロジェクト: shen0100/blueprint
 /**
  * Register the annotation loader.
  *
  * @return void
  */
 protected function registerAnnotationLoader()
 {
     $this->reader->addNamespace('Dingo\\Blueprint\\Annotation');
     $this->reader->addNamespace('Dingo\\Blueprint\\Annotation\\Method');
     AnnotationRegistry::registerLoader(function ($class) {
         $path = __DIR__ . '/' . str_replace(['Dingo\\Blueprint\\', '\\'], ['', DIRECTORY_SEPARATOR], $class) . '.php';
         if (file_exists($path)) {
             require_once $path;
             return true;
         }
     });
 }
コード例 #4
0
 /**
  * @param array $paths
  * @return \Doctrine\Common\Annotations\AnnotationReader
  */
 protected function createAnnotationDriver($paths = array(), $alias = null)
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
         // Register the ORM Annotations in the AnnotationRegistry
         AnnotationRegistry::registerFile(__DIR__ . '/../../../lib/Doctrine/ORM//Mapping/Driver/DoctrineAnnotations.php');
         $reader = new 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\\');
             }
         }
     }
     return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
 }
コード例 #5
0
ファイル: MetaDriver.php プロジェクト: phpcrystal/phpcrystal
 /**
  * @return null
  */
 public function init()
 {
     parent::init();
     $this->annotReader = new SimpleAnnotationReader();
     $this->annotReader->addNamespace(__NAMESPACE__ . '\\Annotation\\Action');
     $this->annotReader->addNamespace(__NAMESPACE__ . '\\Annotation\\Common');
 }
コード例 #6
0
ファイル: DCOM58Test.php プロジェクト: eltondias/Relogio
 public function testIssueSimpleAnnotationReader()
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Doctrine\\Tests\\Common\\Annotations\\Ticket\\Doctrine\\ORM\\Mapping');
     $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__ . "\\MappedClass"));
     $this->assertEquals(1, count($annots));
     $this->assertInstanceOf("Doctrine\\Tests\\Common\\Annotations\\Ticket\\Doctrine\\ORM\\Mapping\\Entity", $annots[0]);
 }
コード例 #7
0
 public function test_get_all_class_names_considers_class_paths_from_config()
 {
     Kohana::$config->load('doctrine')->set('entity_paths', array('Some/Entity/Path' => TRUE, 'Other/Entities' => TRUE));
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $driver = new Doctrine_KohanaAnnotationDriver(new CachedReader($reader, new ArrayCache()), Kohana::include_paths());
     $this->assertEquals(array('Some_Entity_Path_Entity', 'Other_Entities_Entity'), $driver->getAllClassNames());
 }
コード例 #8
0
 /**
  * @return SimpleAnnotationReader
  */
 protected function getAnnotationReader()
 {
     if ($this->annotationReader === null) {
         $this->annotationReader = new SimpleAnnotationReader();
         $this->annotationReader->addNamespace('Supra\\Core\\Doctrine\\Annotation');
     }
     return $this->annotationReader;
 }
コード例 #9
0
 /**
  * @return Reader
  */
 public function getAnnotationReader()
 {
     if (!$this->annotationReader) {
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Oow\\Plugin\\Annotations');
         $this->annotationReader = $reader;
     }
     return $this->annotationReader;
 }
コード例 #10
0
ファイル: AnnotationReader.php プロジェクト: swimson/poncho
 /**
  * Constructor
  *
  * @param EntityManagerInterface $em
  * @param ReaderInterface $reader
  * @param array $namespaces
  * @param CacheProvider $cacheProvider
  */
 public function __construct(EntityManagerInterface $em, ReaderInterface $reader = null, array $namespaces = array('Doctrine\\ORM\\Mapping', 'Mindgruve\\Gordo\\Domain'), CacheProvider $cacheProvider = null)
 {
     $this->em = $em;
     if (!$reader) {
         $reader = new SimpleAnnotationReader();
     }
     foreach ($namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     if ($cacheProvider) {
         $reader = new CachedReader($reader, $cacheProvider);
     }
     $this->reader = $reader;
 }
コード例 #11
0
 /**
  * Gets an annotation.
  *
  * @param  mixed  $from
  * @param  string $name
  * @return Annotation
  */
 protected function getAnnotation($from, $name)
 {
     if (!$this->reader) {
         $this->reader = new SimpleAnnotationReader();
         $this->reader->addNamespace($this->namespace);
     }
     $name = "{$this->namespace}\\{$name}";
     if ($from instanceof \ReflectionClass) {
         $annotation = $this->reader->getClassAnnotation($from, $name);
     } elseif ($from instanceof \ReflectionMethod) {
         $annotation = $this->reader->getMethodAnnotation($from, $name);
     } elseif ($from instanceof \ReflectionProperty) {
         $annotation = $this->reader->getPropertyAnnotation($from, $name);
     }
     return $annotation;
 }
コード例 #12
0
ファイル: Container.php プロジェクト: scdevsummit/phpsc-conf
 /**
  * @return \Doctrine\ORM\Configuration
  */
 protected function getDoctrine_ConfigService()
 {
     $this->services['doctrine.config'] = $instance = new Configuration();
     $baseDir = $this->getParameter('app.baseDir');
     $cache = $this->get('app.cache');
     $instance->setMetadataCacheImpl($cache);
     $instance->setQueryCacheImpl($cache);
     $instance->setResultCacheImpl($cache);
     $instance->setProxyDir($baseDir . $this->getParameter('doctrine.proxy.dir'));
     $instance->setProxyNamespace($this->getParameter('doctrine.proxy.namespace'));
     $instance->setAutoGenerateProxyClasses($this->getParameter('app.devmode'));
     AnnotationRegistry::registerFile($baseDir . 'vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $instance->setMetadataDriverImpl(new AnnotationDriver(new CachedReader($reader, $cache), array($baseDir . $this->getParameter('doctrine.entity.dir'))));
     return $instance;
 }
コード例 #13
0
 /**
  * @param ObjectManager $objectManager
  * @param DoctrineProxyResolver $doctrineProxyResolver
  * @param ReaderInterface $reader
  * @param array $namespaces
  * @param CacheProvider $cacheProvider
  */
 public function __construct(ObjectManager $objectManager, DoctrineProxyResolver $doctrineProxyResolver = null, ReaderInterface $reader = null, array $namespaces = array('Doctrine\\ORM\\Mapping', 'Mindgruve\\Gordo\\Annotations'), CacheProvider $cacheProvider = null)
 {
     $this->objectManager = $objectManager;
     if (!$doctrineProxyResolver) {
         $doctrineProxyResolver = new DoctrineProxyResolver();
     }
     $this->doctrineProxyResolver = $doctrineProxyResolver;
     if (!$reader) {
         $reader = new SimpleAnnotationReader();
     }
     foreach ($namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     if ($cacheProvider) {
         $reader = new CachedReader($reader, $cacheProvider);
     }
     $this->reader = $reader;
 }
コード例 #14
0
ファイル: Extension.php プロジェクト: snake-aas/doctrine
 /**
  * @param \Doctrine\Common\Cache\Cache|NULL
  * @param bool
  * @return \Doctrine\Common\Annotations\Reader
  */
 public static function createAnnotationReader(Cache $cache = NULL, $useSimple = FALSE)
 {
     // force load doctrine annotations
     AnnotationRegistry::registerFile(dirname(ClassType::from('Doctrine\\ORM\\Version')->getFileName()) . '/Mapping/Driver/DoctrineAnnotations.php');
     AnnotationRegistry::registerFile(__DIR__ . '/../Mapping/DiscriminatorEntry.php');
     if ($useSimple) {
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ORM\\Mapping');
     } else {
         $reader = new AnnotationReader();
     }
     if (!$cache) {
         return $reader;
     }
     return new CachedReader($reader, $cache);
 }
コード例 #15
0
ファイル: TestDiscovery.php プロジェクト: nsp15/Drupal8
 /**
  * Discovers all available tests in all extensions.
  *
  * @param string $extension
  *   (optional) The name of an extension to limit discovery to; e.g., 'node'.
  *
  * @return array
  *   An array of tests keyed by the first @group specified in each test's
  *   PHPDoc comment block, and then keyed by class names. For example:
  *   @code
  *     $groups['block'] => array(
  *       'Drupal\block\Tests\BlockTest' => array(
  *         'name' => 'Drupal\block\Tests\BlockTest',
  *         'description' => 'Tests block UI CRUD functionality.',
  *         'group' => 'block',
  *       ),
  *     );
  *   @endcode
  *
  * @throws \ReflectionException
  *   If a discovered test class does not match the expected class name.
  *
  * @todo Remove singular grouping; retain list of groups in 'group' key.
  * @see https://www.drupal.org/node/2296615
  * @todo Add base class groups 'Kernel' + 'Web', complementing 'PHPUnit'.
  */
 public function getTestClasses($extension = NULL)
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Drupal\\simpletest\\Annotation');
     if (!isset($extension)) {
         if ($this->cacheBackend && ($cache = $this->cacheBackend->get('simpletest:discovery:classes'))) {
             return $cache->data;
         }
     }
     $list = array();
     $classmap = $this->findAllClassFiles($extension);
     // Prevent expensive class loader lookups for each reflected test class by
     // registering the complete classmap of test classes to the class loader.
     // This also ensures that test classes are loaded from the discovered
     // pathnames; a namespace/classname mismatch will throw an exception.
     $this->classLoader->addClassMap($classmap);
     foreach ($classmap as $classname => $pathname) {
         $finder = MockFileFinder::create($pathname);
         $parser = new StaticReflectionParser($classname, $finder, TRUE);
         try {
             $info = static::getTestInfo($classname, $parser->getDocComment());
         } catch (MissingGroupException $e) {
             // If the class name ends in Test and is not a migrate table dump.
             if (preg_match('/Test$/', $classname) && strpos($classname, 'migrate_drupal\\Tests\\Table') === FALSE) {
                 throw $e;
             }
             // If the class is @group annotation just skip it. Most likely it is an
             // abstract class, trait or test fixture.
             continue;
         }
         // Skip this test class if it requires unavailable modules.
         // @todo PHPUnit skips tests with unmet requirements when executing a test
         //   (instead of excluding them upfront). Refactor test runner to follow
         //   that approach.
         // @see https://www.drupal.org/node/1273478
         if (!empty($info['requires']['module'])) {
             if (array_diff($info['requires']['module'], $this->availableExtensions['module'])) {
                 continue;
             }
         }
         $list[$info['group']][$classname] = $info;
     }
     // Sort the groups and tests within the groups by name.
     uksort($list, 'strnatcasecmp');
     foreach ($list as &$tests) {
         uksort($tests, 'strnatcasecmp');
     }
     // Allow modules extending core tests to disable originals.
     \Drupal::moduleHandler()->alter('simpletest', $list);
     if (!isset($extension)) {
         if ($this->cacheBackend) {
             $this->cacheBackend->set('simpletest:discovery:classes', $list);
         }
     }
     return $list;
 }
コード例 #16
0
 public static function newInstance($paths = array(), $excludePaths = array())
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('SlimAnnotation\\Mapping\\Annotation');
     $cachedReader = new CachedReader($reader, new ArrayCache());
     AnnotationRegistry::registerFile(__DIR__ . '/SlimAnnotations.php');
     return new SlimAnnotationDriver($cachedReader, $paths, $excludePaths);
 }
コード例 #17
0
 /**
  * Add a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader
  * is true, the notation `@Document` will work, otherwise, the notation `@ODM\Document` will be supported.
  *
  * @param array $paths
  * @param bool  $useSimpleAnnotationReader
  *
  * @return AnnotationDriver
  */
 public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
 {
     AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Annotations/DoctrineAnnotations.php');
     if ($useSimpleAnnotationReader) {
         // Register the ORM Annotations in the AnnotationRegistry
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ODM\\OrientDB\\Mapping\\Annotations');
         $cachedReader = new CachedReader($reader, new ArrayCache());
         return new AnnotationDriver($cachedReader, (array) $paths);
     }
     return new AnnotationDriver(new CachedReader(new AnnotationReader(), new ArrayCache()), (array) $paths);
 }
コード例 #18
0
 /**
  * Add a new default annotation driver with a correctly configured annotation reader.
  * 
  * @param array $paths
  * @return Mapping\Driver\AnnotationDriver
  */
 public function newDefaultAnnotationDriver($paths = array())
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0-DEV', '>=')) {
         // Register the ORM Annotations in the AnnotationRegistry
         AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
         $reader = new AnnotationReader();
         $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ApcCache());
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.3.0-DEV', '>=')) {
             // Register the ORM Annotations in the AnnotationRegistry
             // Done manually according to MongoDB ODM but that breaks existing code quickly
             AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
             $reader = new SimpleAnnotationReader();
             $reader->addNamespace('Doctrine\\OXM\\Mapping');
             $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ApcCache());
         } else {
             if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-DEV', '>=')) {
                 // Register the ORM Annotations in the AnnotationRegistry
                 AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
                 $reader = new AnnotationReader();
                 $reader->setDefaultAnnotationNamespace('Doctrine\\OXM\\Mapping\\');
                 $reader->setIgnoreNotImportedAnnotations(true);
                 $reader->setEnableParsePhpImports(false);
                 $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new \Doctrine\Common\Cache\ApcCache());
             } else {
                 $reader = new AnnotationReader();
                 $reader->setDefaultAnnotationNamespace('Doctrine\\OXM\\Mapping\\');
             }
         }
     }
     return new AnnotationDriver($reader, (array) $paths);
 }
コード例 #19
0
 /**
  * Create an instance of the Kohana annotation driver, which supports loading model files from across the CFS. Also
  * handles registering the Doctrine annotations in the Annotation registry - which would normally be handled by
  * Doctrine\ORM\Configuration::newDefaultAnnotationDriver.
  *
  * @return Doctrine_KohanaAnnotationDriver
  * @see Doctrine\ORM\Configuration::newDefaultAnnotationDriver
  */
 protected function create_annotation_driver()
 {
     $config = $this->config->load('doctrine');
     // Register the Doctrine annotations
     $vendor_path = $config->get('composer_vendor_path');
     AnnotationRegistry::registerFile($vendor_path . 'doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     if ($config->get('use_simple_annotation_reader')) {
         // Register the ORM Annotations in the AnnotationReader
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ORM\\Mapping');
     } else {
         $reader = new AnnotationReader();
     }
     $cachedReader = new CachedReader($reader, new ArrayCache());
     return new Doctrine_KohanaAnnotationDriver($cachedReader, Kohana::include_paths());
 }
コード例 #20
0
ファイル: EngineTrait.php プロジェクト: apioo/fusio-engine
 /**
  * @param array $namespaces
  * @return \Doctrine\Common\Annotations\Reader
  */
 protected function newDoctrineAnnotationImpl(array $namespaces)
 {
     $this->registerAnnotationLoader($namespaces);
     $reader = new Annotations\SimpleAnnotationReader();
     foreach ($namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     return $reader;
 }
コード例 #21
0
 public function addNamespace($namespace)
 {
     $this->reader->addNamespace($namespace);
 }
コード例 #22
0
 /**
  * Get an annotation reader instance.
  *
  * @return \Doctrine\Common\Annotations\SimpleAnnotationReader
  */
 protected function getReader()
 {
     $reader = new SimpleAnnotationReader();
     foreach ($this->namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     return $reader;
 }
コード例 #23
0
 public static function getService(ArrayObject $config, Loops $loops)
 {
     if (@$config->simple) {
         $annotation_reader = new SimpleAnnotationReader();
         $annotation_reader->addNamespace("Loops\\Annotations");
         $annotation_reader->addNamespace("Loops\\Annotations\\Access");
         $annotation_reader->addNamespace("Loops\\Annotations\\Admin");
         $annotation_reader->addNamespace("Loops\\Annotations\\Element");
         $annotation_reader->addNamespace("Loops\\Annotations\\Element\\Doctrine");
         $annotation_reader->addNamespace("Loops\\Annotations\\Event\\Form");
         $annotation_reader->addNamespace("Loops\\Annotations\\Event\\Renderer");
         $annotation_reader->addNamespace("Loops\\Annotations\\Event\\Session");
         $annotation_reader->addNamespace("Loops\\Annotations\\Form");
         $annotation_reader->addNamespace("Loops\\Annotations\\Form\\Element");
         $annotation_reader->addNamespace("Loops\\Annotations\\Navigation");
         $annotation_reader->addNamespace("Loops\\Annotations\\Session");
         return $annotation_reader;
     } else {
         return new AnnotationReader();
     }
 }
コード例 #24
0
 protected function getDomainObjectAnnotations()
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Oneup\\AclBundle\\Mapping\\Annotation');
     $object = new \ReflectionClass('Oneup\\AclBundle\\Tests\\Model\\SomeObject');
     return $reader->getClassAnnotations($object);
 }