コード例 #1
0
 protected function createViewModelForMenuItemIterator(\RecursiveIterator $rit)
 {
     $itemsViews = array();
     $rit->rewind();
     while ($rit->valid()) {
         $item = $rit->current();
         $view = $this->createViewModelForMenuItem($item);
         if ($rit->hasChildren()) {
             $childrenView = $this->createViewModelForMenuItemIterator($rit->getChildren());
             $view->set('children', $childrenView);
         }
         $itemsViews[] = $view;
         $rit->next();
     }
     return $itemsViews;
 }
コード例 #2
0
ファイル: Generator.php プロジェクト: lapistano/proxy-object
 /**
  * Walks recursivly throught an array and concatinates the found info to a string.
  *
  * @param \RecursiveIterator $iterator
  *
  * @return string
  */
 protected static function traverseStructure($iterator)
 {
     $children = '';
     while ($iterator->valid()) {
         if ($iterator->hasChildren()) {
             $current = 'array (' . self::traverseStructure($iterator->getChildren()) . '), ';
         } else {
             $current = "'" . $iterator->current() . "', ";
         }
         $key = $iterator->key();
         if (is_numeric($key)) {
             $children .= $key . " => " . $current;
         } else {
             $children .= "'" . $key . "' => " . $current;
         }
         $iterator->next();
     }
     return $children;
 }