예제 #1
0
 /**
  * Build the initial tree
  *
  * @param Directory $node
  * @param array $ignore
  */
 public static function build($node, $ignore)
 {
     if (($it = new \FilesystemIterator($node->getPath())) == false) {
         return;
     }
     if ($node instanceof Root) {
         // Ignore config.json in the root directory
         $ignore['files'][] = 'config.json';
     }
     /** @var \SplFileInfo $file */
     foreach ($it as $file) {
         if (static::isIgnored($file, $ignore)) {
             continue;
         }
         if ($file->isDir()) {
             $new = new Directory($node, static::removeSortingInformations($file->getFilename()), $file);
             $new->setName(static::getName($file->getPathName()));
             $new->setTitle(str_replace('_', ' ', static::removeSortingInformations($new->getName())));
             static::build($new, $ignore);
         } else {
             static::createContent($node, $file);
         }
     }
     $node->sort();
 }