コード例 #1
0
 /**
  * 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
0
ファイル: DocParser.php プロジェクト: laiello/masfletes
 /**
  * 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
0
 /**
  * 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();
 }