當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Reader::addNamespace方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Annotations\Reader::addNamespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reader::addNamespace方法的具體用法?PHP Reader::addNamespace怎麽用?PHP Reader::addNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Annotations\Reader的用法示例。


在下文中一共展示了Reader::addNamespace方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onConfigureRoute

 /**
  * Reads the "@Access" annotations from the controller stores them in the "access" route option.
  */
 public function onConfigureRoute($event, $route)
 {
     if (!$this->reader) {
         $this->reader = new SimpleAnnotationReader();
         $this->reader->addNamespace('Pagekit\\User\\Annotation');
     }
     if (!$route->getControllerClass()) {
         return;
     }
     $access = [];
     foreach (array_merge($this->reader->getClassAnnotations($route->getControllerClass()), $this->reader->getMethodAnnotations($route->getControllerMethod())) as $annot) {
         if (!$annot instanceof Access) {
             continue;
         }
         if ($expression = $annot->getExpression()) {
             $access[] = $expression;
         }
         if ($admin = $annot->getAdmin() !== null) {
             $route->setPath('admin' . rtrim($route->getPath(), '/'));
             $permission = 'system: access admin area';
             if ($admin) {
                 $access[] = $permission;
             } else {
                 if ($key = array_search($permission, $access)) {
                     unset($access[$key]);
                 }
             }
         }
     }
     if ($access) {
         $route->setDefault('_access', array_unique($access));
     }
 }
開發者ID:LibraryOfLawrence,項目名稱:pagekit,代碼行數:36,代碼來源:AccessListener.php

示例2: setUp

 protected function setUp()
 {
     AnnotationRegistry::registerLoader('class_exists');
     $this->reader = new SimpleAnnotationReader();
     $this->reader->addNamespace('Bazinga\\Bundle\\GeocoderBundle\\Mapping\\Annotations');
     $this->driver = new AnnotationDriver($this->reader);
 }
開發者ID:nicolassing,項目名稱:BazingaGeocoderBundle,代碼行數:7,代碼來源:AnnotationDriverTest.php

示例3: getAnnotationReader

 /**
  * Gets the used doctrine annotation reader.
  *
  * @return \Doctrine\Common\Annotations\Reader
  *   The annotation reader.
  */
 protected function getAnnotationReader()
 {
     if (!isset($this->annotationReader)) {
         $this->annotationReader = new SimpleAnnotationReader();
         // Add the namespaces from the main plugin annotation, like @EntityType.
         $namespace = substr($this->pluginDefinitionAnnotationName, 0, strrpos($this->pluginDefinitionAnnotationName, '\\'));
         $this->annotationReader->addNamespace($namespace);
     }
     return $this->annotationReader;
 }
開發者ID:EarthTeam,項目名稱:earthteam.net,代碼行數:16,代碼來源:AnnotatedClassDiscovery.php

示例4: getAnnotationReader

 /**
  * Get the annotation reader instance.
  *
  * @return Reader
  */
 protected function getAnnotationReader()
 {
     if (!$this->reader) {
         $this->reader = new SimpleAnnotationReader();
         $this->reader->addNamespace('Pagekit\\Routing\\Annotation');
     }
     return $this->reader;
 }
開發者ID:LibraryOfLawrence,項目名稱:pagekit,代碼行數:13,代碼來源:AnnotationLoader.php

示例5: getAnnotationReader

 /**
  * @return Reader The annotation reader
  */
 public function getAnnotationReader()
 {
     if ($this->annotationReader == null) {
         AnnotationRegistry::registerAutoloadNamespace('DI\\Annotation', __DIR__ . '/../../../');
         $this->annotationReader = new SimpleAnnotationReader();
         $this->annotationReader->addNamespace('DI\\Annotation');
     }
     return $this->annotationReader;
 }
開發者ID:jdreesen,項目名稱:PHP-DI,代碼行數:12,代碼來源:AnnotationReader.php

示例6: onConfigureRoute

 /**
  * Reads the "@Access" annotations from the controller stores them in the "access" route option.
  *
  * @param ConfigureRouteEvent $event
  */
 public function onConfigureRoute(ConfigureRouteEvent $event)
 {
     if (!$this->reader) {
         $this->reader = new SimpleAnnotationReader();
         $this->reader->addNamespace('Pagekit\\User\\Annotation');
     }
     $admin = false;
     $access = [];
     foreach ($this->reader->getClassAnnotations($event->getClass()) as $annot) {
         if ($annot instanceof Access) {
             if ($expression = $annot->getExpression()) {
                 $access[] = $expression;
             }
             if ($annot->getAdmin()) {
                 $admin = true;
             }
         }
     }
     foreach ($this->reader->getMethodAnnotations($event->getMethod()) as $annot) {
         if ($annot instanceof Access) {
             if ($expression = $annot->getExpression()) {
                 $access[] = $expression;
             }
             if ($annot->getAdmin()) {
                 $admin = true;
             }
         }
     }
     $route = $event->getRoute();
     if ($admin) {
         $route->setPath(rtrim('admin' . $route->getPath(), '/'));
         $access[] = 'system: access admin area';
     }
     if ($access) {
         $route->setDefault('_access', array_unique($access));
     }
 }
開發者ID:amirkheirabadi,項目名稱:pagekit,代碼行數:42,代碼來源:AccessListener.php


注:本文中的Doctrine\Common\Annotations\Reader::addNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。