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


PHP ClassType::getAnnotation方法代碼示例

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


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

示例1: prepareRepositories

 /**
  * @return array
  */
 protected function prepareRepositories()
 {
     $builder = $this->getContainerBuilder();
     $repositories = [];
     foreach ($builder->findByType(Repository::class) as $repositoryName => $definition) {
         $repositoryClass = $definition->getClass();
         $reflection = new ClassType($repositoryClass);
         $name = $reflection->getAnnotation('entity2');
         if ($name === NULL) {
             $name = $this->createEntityName($repositoryClass);
         }
         $repositories[$name] = $repositoryClass;
         $mapperClass = Strings::replace($repositoryClass, '~Repository$~', 'Mapper');
         $mapperName = $builder->getByType($mapperClass);
         if ($mapperName === NULL) {
             $mapperName = Strings::replace($repositoryName, '~Repository$~', 'Mapper');
             $builder->addDefinition($mapperName)->setClass($mapperClass)->setArguments(['cache' => '@' . $this->prefix('cache')]);
         } else {
             $builder->getDefinition($mapperName)->setArguments(['cache' => '@' . $this->prefix('cache')]);
         }
         $definition->setArguments(['mapper' => '@' . $mapperName, 'dependencyProvider' => '@' . $this->prefix('dependencyProvider')]);
         $definition->addSetup('setModel', ['@' . $this->prefix('model')]);
     }
     return $repositories;
 }
開發者ID:sw2eu,項目名稱:dynamic-model,代碼行數:28,代碼來源:DynamicOrmExtension.php

示例2: parseAnnotations

	/**
	 * @param string
	 * @param string
	 * @return array
	 */
	public static function parseAnnotations($class, $method = NULL)
	{
		if (strpos($class, '::') !== FALSE && !$method) {
			list($class, $method) = explode('::', $class);
		}

		$ref = new Reflection\Method($class, $method);
		$cRef = new Reflection\ClassType($class);
		$anntations = (array)$ref->getAnnotation('allowed');

		$role = isset($anntations['role']) ? $anntations['role']
			: ($ref->hasAnnotation('role') ? $ref->getAnnotation('role') : NULL);

		$resource = isset($anntations['resource']) ? $anntations['resource']
			: ($ref->hasAnnotation('resource')
			? $ref->getAnnotation('resource')
				: ($cRef->hasAnnotation('resource') ? $cRef->getAnnotation('resource') : NULL));

		$privilege = isset($anntations['privilege']) ? $anntations['privilege']
			: ($ref->hasAnnotation('privilege') ? $ref->getAnnotation('privilege') : NULL);

		return array(
			static::ROLE => $role,
			static::RESOURCE => $resource,
			static::PRIVILEGE => $privilege,
		);
	}
開發者ID:norbe,項目名稱:framework,代碼行數:32,代碼來源:Authorizator.php

示例3: init

 public function init()
 {
     if ($this->presenterMap !== NULL) {
         return;
     }
     $this->presenterMap = $this->nameMap = array();
     foreach ($this->findClasses() as $className) {
         $class = new ClassType($className);
         $presenter = ltrim($class->getAnnotation('Presenter'), ':');
         $name = $class->getAnnotation('Name');
         if ($presenter) {
             $this->presenterMap[substr($presenter, -1) === ':' ? $presenter . 'default' : $presenter] = $className;
         }
         if ($name) {
             $this->nameMap[$className] = $name;
         }
     }
 }
開發者ID:kdyby,項目名稱:selenium,代碼行數:18,代碼來源:Sitemap.php

示例4: walkClassHierarchy

 private function walkClassHierarchy(ClassType $classType, &$expressions)
 {
     $parentClass = $classType->getParentClass();
     if ($parentClass) {
         $this->walkClassHierarchy($parentClass, $expressions);
     }
     $annotation = $classType->getAnnotation('Security');
     if ($annotation) {
         if (!is_string($annotation)) {
             throw new \InvalidArgumentException('Security annotation must be simple string with expression.');
         }
         $expressions[] = new Expression($annotation);
     }
 }
開發者ID:zycon42,項目名稱:security,代碼行數:14,代碼來源:PresenterRequirementsChecker.php


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