Doctrine\Common\Annotations\FileCacheReader::getClassAnnotations PHP Method

getClassAnnotations() public method

{@inheritDoc}
public getClassAnnotations ( ReflectionClass $class )
$class ReflectionClass
    public function getClassAnnotations(\ReflectionClass $class)
    {
        if (!isset($this->classNameHashes[$class->name])) {
            $this->classNameHashes[$class->name] = sha1($class->name);
        }
        $key = $this->classNameHashes[$class->name];
        if (isset($this->loadedAnnotations[$key])) {
            return $this->loadedAnnotations[$key];
        }
        $path = $this->dir . '/' . strtr($key, '\\', '-') . '.cache.php';
        if (!is_file($path)) {
            $annot = $this->reader->getClassAnnotations($class);
            $this->saveCacheFile($path, $annot);
            return $this->loadedAnnotations[$key] = $annot;
        }
        if ($this->debug && false !== ($filename = $class->getFilename()) && filemtime($path) < filemtime($filename)) {
            @unlink($path);
            $annot = $this->reader->getClassAnnotations($class);
            $this->saveCacheFile($path, $annot);
            return $this->loadedAnnotations[$key] = $annot;
        }
        return $this->loadedAnnotations[$key] = (include $path);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param ReflectionClass $class
  * @return array
  */
 public function read(ReflectionClass $class)
 {
     /**
      * @var DrupalCommand $definition 
     */
     $definitions = $this->reader->getClassAnnotations($class);
     $dependencies = [];
     foreach ($definitions as $definition) {
         if ($definition instanceof DrupalCommand) {
             foreach ($definition->dependencies as $dependency) {
                 $dependencies[] = $dependency;
             }
         }
     }
     return $dependencies;
 }