findArray() public method

Plus all it's children-children recursively and returns an array with all of them I you want to do further searching on it, you should rather use the Generator-version ->find() to improve memory-usage
public findArray ( string $type ) : array
$type string the node type to search for
return array an array containing all found children
示例#1
0
 /**
  * Finds all mixins and loops them through handleMixin.
  *
  * Duplicated mixins will throw an exception if the replaceMixins-options
  * is false
  *
  * @param Node $node the node to search mixins in
  *
  * @return $this
  * @throws Exception when a mixin name occurs twice and replaceMixins is false
  */
 protected function handleMixins(Node $node)
 {
     $mixins = $node->findArray('mixin');
     //Save all mixins in $this->mixins for our mixinCalls to reference them
     foreach ($mixins as $mixinNode) {
         if (isset($this->mixins[$mixinNode->name]) && !$this->options['replaceMixins']) {
             $this->throwException("Duplicate mixin name {$mixinNode->name}", $mixinNode);
         }
         $this->mixins[$mixinNode->name] = $mixinNode;
     }
     //Handle the mixins
     foreach ($this->mixins as $mixinNode) {
         $this->handleMixin($mixinNode);
     }
     return $this;
 }
示例#2
0
 /**
  * Finds all mixins and loops them through handleMixin.
  *
  * Duplicated mixins will throw an exception if the replaceMixins-options
  * is false
  *
  * @param Node $node the node to search mixins in
  *
  * @return $this
  * @throws Exception when a mixin name occurs twice and replaceMixins is false
  */
 protected function handleMixins(Node $node)
 {
     $mixins = $node->findArray('mixin');
     //Save all mixins in $this->mixins for our mixinCalls to reference them
     foreach ($mixins as $mixinNode) {
         if (isset($this->mixins[$mixinNode->name]) && !$this->options['replace_mixins']) {
             $this->throwException("A mixin with the name [{$mixinNode->name}] is already defined. Rename the it or enable the" . "[`replace_mixins`]-option to be able to overwrite it", $mixinNode);
         } else {
             if (isset($this->mixins[$mixinNode->name])) {
                 $this->mixins[$mixinNode->name]->parent->remove($this->mixins[$mixinNode->name]);
             }
         }
         $this->mixins[$mixinNode->name] = $mixinNode;
     }
     //Handle the mixins
     foreach ($this->mixins as $mixinNode) {
         $this->handleMixin($mixinNode);
     }
     return $this;
 }