Esempio n. 1
0
 /**
  * Gets elements by path
  * sequence (in all xml files)
  *
  * @param  string $path
  * @return array
  */
 public function getElementsByPath($path)
 {
     $elements = array();
     foreach ($this->xmls as $xml) {
         $result = $xml->getElementsByPath($path);
         if (false != $result) {
             $elements[] = $result;
         }
     }
     return ArrayHelper::flatten($elements);
 }
Esempio n. 2
0
 /**
  * Gets all vars also from
  * it's parent
  *
  * @return array
  */
 public function getVarsRecursive()
 {
     $vars = array();
     $vars[] = $this->getVars();
     $current = $this->parent;
     while (!is_null($current)) {
         $vars[] = array_reverse($current->getVars());
         $current = $current->getParent();
     }
     $vars = ArrayHelper::flatten($vars);
     $vars = ArrayHelper::clean($vars);
     $vars = array_reverse($vars);
     return $vars;
 }
Esempio n. 3
0
 /**
  * Gets a list of all elements with this name.
  * Recursive strategy enabled by default.
  * It also collects all results if the
  * parameter is set to true (Without reference
  * variables)
  *
  * @param  string  $name
  * @param  boolean $recursive
  * @param  boolean $collect
  * @return Element|boolean|array
  */
 public function getChildrenByName($name, $collect = true, $recursive = true)
 {
     $children = array();
     for ($i = 0; $i < count($this->children); $i++) {
         $child = $this->children[$i];
         if ($child->getName() == $name) {
             if (!$collect) {
                 return $child;
             } else {
                 $children[] = $child;
             }
         }
         if ($child->countChildren() > 0 && $recursive) {
             if (!$collect) {
                 $depthChild = $child->getChildByName($name, $recursive);
                 if ($depthChild) {
                     return $depthChild;
                 }
             } else {
                 $depthChilds = $child->getChildrenByName($name, $collect, $recursive);
                 if ($depthChilds) {
                     $children[] = $depthChilds;
                 }
             }
         }
     }
     if (true == $collect) {
         return ArrayHelper::flatten($children);
     }
     return false;
 }