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


PHP AnnotationRegistry::reset方法代码示例

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


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

示例1: registerAnnotationLoader

 protected static function registerAnnotationLoader(array $namespaces)
 {
     AnnotationRegistry::reset();
     AnnotationRegistry::registerLoader(function ($class) use($namespaces) {
         foreach ($namespaces as $namespace) {
             if (strpos($class, $namespace) === 0) {
                 spl_autoload_call($class);
                 return class_exists($class, false);
             }
         }
     });
 }
开发者ID:seytar,项目名称:psx,代码行数:12,代码来源:Bootstrap.php

示例2: testBootRegistersAnnotationInLoader

 /**
  * Test that calling boot() registers our annotation in the AnnotationRegistry.
  *
  * @return void
  */
 public function testBootRegistersAnnotationInLoader()
 {
     $bundle = new TensideCoreBundle();
     AnnotationRegistry::reset();
     $this->assertFalse(AnnotationRegistry::loadAnnotationClass('Tenside\\CoreBundle\\Annotation\\ApiDescription'));
     $this->assertFalse(class_exists('Tenside\\CoreBundle\\Annotation\\ApiDescription', false));
     $bundle->boot();
     $this->assertFalse(AnnotationRegistry::loadAnnotationClass('NonExistant\\Annotation'));
     // Ensure the class does not get loaded by requiring another annotation.
     $this->assertFalse(class_exists('Tenside\\CoreBundle\\Annotation\\ApiDescription', false));
     $this->assertTrue(AnnotationRegistry::loadAnnotationClass('Tenside\\CoreBundle\\Annotation\\ApiDescription'));
     $this->assertTrue(class_exists('Tenside\\CoreBundle\\Annotation\\ApiDescription', false));
 }
开发者ID:tenside,项目名称:core-bundle,代码行数:18,代码来源:TensideCoreBundleTest.php

示例3: getDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDefinitions()
 {
     $definitions = array();
     $reader = $this->getAnnotationReader();
     // Clear the annotation loaders of any previous annotation classes.
     AnnotationRegistry::reset();
     // Register the namespaces of classes that can be used for annotations.
     AnnotationRegistry::registerLoader('class_exists');
     // Search for classes within all PSR-0 namespace locations.
     foreach ($this->getPluginNamespaces() as $namespace => $dirs) {
         foreach ($dirs as $dir) {
             if (file_exists($dir)) {
                 $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS));
                 foreach ($iterator as $fileinfo) {
                     if ($fileinfo->getExtension() == 'php') {
                         $sub_path = $iterator->getSubIterator()->getSubPath();
                         $sub_path = $sub_path ? str_replace('/', '\\', $sub_path) . '\\' : '';
                         $class = $namespace . '\\' . str_replace('/', '\\', $this->pluginManagerDefinition['directory']) . '\\' . $sub_path . $fileinfo->getBasename('.php');
                         // The filename is already known, so there is no need to find the
                         // file. However, StaticReflectionParser needs a finder, so use a
                         // mock version.
                         $finder = MockFileFinder::create($fileinfo->getPathName());
                         $parser = new StaticReflectionParser($class, $finder, TRUE);
                         if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass(), $this->pluginDefinitionAnnotationName)) {
                             $this->prepareAnnotationDefinition($annotation, $class);
                             $definitions[$annotation->getId()] = $annotation->get();
                         }
                     }
                 }
             }
         }
     }
     // Don't let annotation loaders pile up.
     AnnotationRegistry::reset();
     return $definitions;
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:39,代码来源:AnnotatedClassDiscovery.php

示例4: getDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDefinitions()
 {
     $definitions = array();
     $reader = $this->getAnnotationReader();
     // Clear the annotation loaders of any previous annotation classes.
     AnnotationRegistry::reset();
     // Register the namespaces of classes that can be used for annotations.
     AnnotationRegistry::registerLoader('class_exists');
     // Search for classes within all PSR-0 namespace locations.
     foreach ($this->getPluginNamespaces() as $namespace => $dirs) {
         foreach ($dirs as $dir) {
             if (file_exists($dir)) {
                 $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS));
                 foreach ($iterator as $fileinfo) {
                     if ($fileinfo->getExtension() == 'php') {
                         if ($cached = $this->fileCache->get($fileinfo->getPathName())) {
                             if (isset($cached['id'])) {
                                 // Explicitly unserialize this to create a new object instance.
                                 $definitions[$cached['id']] = unserialize($cached['content']);
                             }
                             continue;
                         }
                         $sub_path = $iterator->getSubIterator()->getSubPath();
                         $sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : '';
                         $class = $namespace . '\\' . $sub_path . $fileinfo->getBasename('.php');
                         // The filename is already known, so there is no need to find the
                         // file. However, StaticReflectionParser needs a finder, so use a
                         // mock version.
                         $finder = MockFileFinder::create($fileinfo->getPathName());
                         $parser = new BaseStaticReflectionParser($class, $finder, FALSE);
                         /** @var $annotation \Drupal\Component\Annotation\AnnotationInterface */
                         if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass(), $this->pluginDefinitionAnnotationName)) {
                             $this->prepareAnnotationDefinition($annotation, $class, $parser);
                             $id = $annotation->getId();
                             $content = $annotation->get();
                             $definitions[$id] = $content;
                             // Explicitly serialize this to create a new object instance.
                             $this->fileCache->set($fileinfo->getPathName(), ['id' => $id, 'content' => serialize($content)]);
                         } else {
                             // Store a NULL object, so the file is not reparsed again.
                             $this->fileCache->set($fileinfo->getPathName(), [NULL]);
                         }
                     }
                 }
             }
         }
     }
     // Don't let annotation loaders pile up.
     AnnotationRegistry::reset();
     return $definitions;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:54,代码来源:AnnotatedClassDiscoveryAutomatedProviders.php

示例5: registerCommands

 private function registerCommands()
 {
     if ($this->container->hasParameter('drupal.commands')) {
         $consoleCommands = $this->container->getParameter('drupal.commands');
     } else {
         $consoleCommands = array_keys($this->container->findTaggedServiceIds('drupal.command'));
         $this->container->setParameter('console.warning', 'application.site.errors.settings');
     }
     //        // @TODO add auto-discovery of chain files
     //        $chainCommands['create:bulk:data'] = [
     //            'file' => '/Users/jmolivas/.console/chain/create-data.yml'
     //        ];
     //
     //        foreach ($chainCommands as $name => $chainCommand) {
     //            $file = $chainCommand['file'];
     //            $command = new ChainRegister($name, $file);
     //            $this->add($command);
     //        }
     $serviceDefinitions = [];
     $annotationValidator = null;
     if ($this->container->hasParameter('console.service_definitions')) {
         $serviceDefinitions = $this->container->getParameter('console.service_definitions');
         /**
          * @var AnnotationValidator $annotationValidator
          */
         $annotationValidator = $this->container->get('console.annotation_validator');
     }
     $aliases = $this->container->get('console.configuration_manager')->getConfiguration()->get('application.commands.aliases') ?: [];
     foreach ($consoleCommands as $name) {
         // Some commands call AnnotationRegistry::reset,
         // we need to ensure the AnnotationRegistry is correctly defined.
         AnnotationRegistry::reset();
         AnnotationRegistry::registerLoader([\Drupal::service('class_loader'), "loadClass"]);
         if (!$this->container->has($name)) {
             continue;
         }
         if ($annotationValidator) {
             if (!($serviceDefinition = $serviceDefinitions[$name])) {
                 continue;
             }
             if (!$annotationValidator->isValidCommand($serviceDefinition->getClass())) {
                 continue;
             }
         }
         try {
             $command = $this->container->get($name);
         } catch (\Exception $e) {
             continue;
         }
         if (!$command) {
             continue;
         }
         if (method_exists($command, 'setTranslator')) {
             $command->setTranslator($this->container->get('console.translator_manager'));
         }
         if (method_exists($command, 'setContainer')) {
             $command->setContainer($this->container->get('service_container'));
         }
         if (array_key_exists($command->getName(), $aliases)) {
             $commandAliases = $aliases[$command->getName()];
             if (!is_array($commandAliases)) {
                 $commandAliases = [$commandAliases];
             }
             $command->setAliases($commandAliases);
         }
         $this->add($command);
     }
 }
开发者ID:GDrupal,项目名称:DrupalConsole,代码行数:68,代码来源:Application.php


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