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