Beispiel #1
0
 /**
  *
  */
 public function prepare()
 {
     $this->fetched = $this->fetch();
     $this->fetched->rewind();
     $this->filtered = $this->filter($this->fetched);
     $this->filtered->rewind();
     $this->sorted = $this->sort($this->filtered);
     $this->sorted->rewind();
 }
Beispiel #2
0
 public function scanControllers(\FilesystemIterator $iterator)
 {
     $iterator->rewind();
     foreach ($iterator as $resource) {
         $matches = array();
         if ($resource->isFile()) {
             preg_match('/((\\/?[A-z]*)+(([A-Z]{1})+[a-z])*Controller\\.php)/', $resource->getRealPath(), $matches);
             if (isset($matches[0]) && !is_null($matches[0])) {
                 // To improve later
                 $class = array_filter(preg_split('/\\b[a-z]+\\b/', $resource->getRealPath()));
                 $class = $class[count($class) - 1];
                 $class = $class[0] == '/' ? substr($class, 1, strlen($class)) : $class;
                 $class = str_replace(array('.', '.php'), '', $class);
                 $class = str_replace('/', '\\', $class);
                 $controller = new $class();
                 if ($controller instanceof AbstractController) {
                     $this->controllerStack->attach(new $class($this->application));
                 } else {
                     unset($controller);
                 }
             }
         }
     }
 }
 /**
  * Overwriting the default `rewind()` method to skip files beginning with a dot if so
  *
  * It the flag `SKIP_DOTTED` is active, this will skip files beginning with a dot.
  *
  * @return void
  */
 public function rewind()
 {
     parent::rewind();
     if ($this->valid() && $this->getFlags() & WebFilesystemIterator::SKIP_DOTTED) {
         $this->_skipDottedIfSo();
     }
 }
Beispiel #4
0
<?php

$sample_dir = __DIR__ . '/../../sample_dir';
$iterator = new FilesystemIterator($sample_dir, FilesystemIterator::KEY_AS_FILENAME);
$a = $iterator->key();
$iterator->next();
$b = $iterator->key();
$iterator->rewind();
$c = $iterator->key();
var_dump($a == $b);
var_dump($a == $c);