本文整理汇总了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;
}
示例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,
);
}
示例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;
}
}
}
示例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);
}
}