public static function searching(IContainer $aParent, $aCallback)
 {
     $arrRes = array();
     foreach ($aParent->iterator() as $aChild) {
         if (call_user_func_array($aCallback, array($aChild))) {
             $arrRes[] = $aChild;
         }
         // 递归child
         $arrRes = array_merge($arrRes, self::searching($aChild, $aCallback));
     }
     return $arrRes;
 }
Exemple #2
0
 /**
  * @return IView
  */
 public static function findXPath(IContainer $aViewContainer, $sViewXPath)
 {
     $arrPath = explode('/', $sViewXPath);
     $aView = $aViewContainer;
     while (($sViewName = array_shift($arrPath)) !== null) {
         if (empty($sViewName)) {
             continue;
         }
         if (!($aView = $aViewContainer->getByName($sViewName))) {
             return null;
         }
         $aViewContainer = $aView;
     }
     return $aView;
 }