/** * 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; }
/** * 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; }