コード例 #1
0
ファイル: Result.php プロジェクト: ralfeggert/zftool
 /**
  * Convenient access to the last handler return value.
  *
  * If the collection is empty, returns null. Otherwise, returns value
  * returned by last handler.
  *
  * @return mixed The last handler return value
  */
 public function last()
 {
     if (count($this) === 0) {
         return null;
     }
     return parent::top();
 }
 /**
  * Builds a Hierarchy of every entity in the Class metadata.
  * @param ClassMetadataFactory $metadataFactory
  * @return MetadataNode[]
  */
 protected function buildHierarchy(ClassMetadataFactory $metadataFactory)
 {
     $this->hierarchy = array();
     $stack = new SplStack();
     foreach ($metadataFactory->getAllMetadata() as $metadata) {
         $stack->push($metadata->getName());
     }
     while (!$stack->isEmpty()) {
         $meta = $metadataFactory->getMetadataFor($stack->pop());
         $name = $meta->getName();
         $node = $this->getNode($name);
         $parent = $meta->getReflectionClass()->getParentClass();
         if ($parent != null && $metadataFactory->hasMetadataFor($parent->getName())) {
             $parentNode = $this->getNode($metadataFactory->getMetadataFor($parent->getName())->getName());
             $node->setParent($parentNode);
             $parentNode->addChild($node);
         }
     }
     return $this->hierarchy;
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function collect()
 {
     $collection = array();
     foreach ($this->getPaths() as $path) {
         $locations = new SplStack();
         $pathInfo = new SplFileInfo($path);
         $locations->push($pathInfo);
         $basePath = $this->normalizePath($pathInfo->getRealPath());
         while (!$locations->isEmpty()) {
             /** @var SplFileInfo $pathInfo */
             $pathInfo = $locations->pop();
             if (!$pathInfo->isReadable()) {
                 continue;
             }
             if ($pathInfo->isDir()) {
                 $dir = new DirectoryResource($pathInfo->getRealPath());
                 foreach ($dir as $resource) {
                     $locations->push(new SplFileInfo($resource));
                 }
             } elseif (!isset($collection[$pathInfo->getPath()])) {
                 $collection[] = substr($pathInfo->getRealPath(), strlen($basePath));
             }
         }
     }
     return $collection;
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function collect()
 {
     $collection = array();
     foreach ($this->aliases as $alias => $path) {
         $locations = new SplStack();
         $pathInfo = new SplFileInfo($path);
         $locations->push($pathInfo);
         $basePath = $this->normalizePath($pathInfo->getRealPath());
         while (!$locations->isEmpty()) {
             /** @var SplFileInfo $pathInfo */
             $pathInfo = $locations->pop();
             if (!$pathInfo->isReadable()) {
                 throw new RuntimeException(sprintf('%s is not readable.', $pathInfo->getPath()));
             }
             if ($pathInfo->isDir()) {
                 foreach (new DirectoryResource($pathInfo->getRealPath()) as $resource) {
                     $locations->push(new SplFileInfo($resource));
                 }
             } else {
                 $collection[] = $alias . substr($pathInfo->getRealPath(), strlen($basePath));
             }
         }
     }
     return array_unique($collection);
 }