当前位置: 首页>>代码示例>>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;未经允许,请勿转载。