Nette\Reflection\ClassType::hasAnnotation PHP Метод

hasAnnotation() публичный Метод

Has class specified annotation?
public hasAnnotation ( $name ) : boolean
Результат boolean
    public function hasAnnotation($name)
    {
        $res = AnnotationsParser::getAll($this);
        return !empty($res[$name]);
    }

Usage Example

Пример #1
0
	/**
	 * @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,
		);
	}
All Usage Examples Of Nette\Reflection\ClassType::hasAnnotation