本文整理汇总了PHP中Doctrine\Common\Annotations\AnnotationRegistry::loadAnnotationClass方法的典型用法代码示例。如果您正苦于以下问题:PHP AnnotationRegistry::loadAnnotationClass方法的具体用法?PHP AnnotationRegistry::loadAnnotationClass怎么用?PHP AnnotationRegistry::loadAnnotationClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Annotations\AnnotationRegistry
的用法示例。
在下文中一共展示了AnnotationRegistry::loadAnnotationClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBootRegistersAnnotationInLoader
/**
* Test that calling boot() registers our annotation in the AnnotationRegistry.
*
* @return void
*/
public function testBootRegistersAnnotationInLoader()
{
$bundle = new TensideCoreBundle();
AnnotationRegistry::reset();
$this->assertFalse(AnnotationRegistry::loadAnnotationClass('Tenside\\CoreBundle\\Annotation\\ApiDescription'));
$this->assertFalse(class_exists('Tenside\\CoreBundle\\Annotation\\ApiDescription', false));
$bundle->boot();
$this->assertFalse(AnnotationRegistry::loadAnnotationClass('NonExistant\\Annotation'));
// Ensure the class does not get loaded by requiring another annotation.
$this->assertFalse(class_exists('Tenside\\CoreBundle\\Annotation\\ApiDescription', false));
$this->assertTrue(AnnotationRegistry::loadAnnotationClass('Tenside\\CoreBundle\\Annotation\\ApiDescription'));
$this->assertTrue(class_exists('Tenside\\CoreBundle\\Annotation\\ApiDescription', false));
}
示例2: classExists
/**
* Attempt to check if a class exists or not. This never goes through the PHP autoloading mechanism
* but uses the {@link AnnotationRegistry} to load classes.
*
* @param string $fqcn
* @return boolean
*/
private function classExists($fqcn)
{
if (isset($this->classExists[$fqcn])) {
return $this->classExists[$fqcn];
}
// first check if the class already exists, maybe loaded through another AnnotationReader
if (class_exists($fqcn, false)) {
return $this->classExists[$fqcn] = true;
}
// final check, does this class exist?
return $this->classExists[$fqcn] = AnnotationRegistry::loadAnnotationClass($fqcn);
}
示例3: annotationClass
/**
* Get annotation object
*
* @param string $name
*
* @return object
* @throws Doctrine\Common\Annotations\AnnotationException
*/
static function annotationClass($name)
{
if (!AnnotationRegistry::loadAnnotationClass($name)) {
throw new \Doctrine\Common\Annotations\AnnotationException('Annotation ' . $name . ' - not exists');
}
return new $name();
}