Goetas\Twital\Node\UseNode::visit PHP Method

visit() public method

public visit ( DOMElement $node, Compiler $context )
$node DOMElement
$context Goetas\Twital\Compiler
    public function visit(\DOMElement $node, Compiler $context)
    {
        $code = "use ";
        if ($node->hasAttribute("from")) {
            $code .= '"' . $node->getAttribute("from") . '"';
        } else {
            throw new Exception("The 'from' attribute is required");
        }
        if ($node->hasAttribute("with")) {
            $code .= " with " . $node->getAttribute("with");
        }
        $pi = $context->createControlNode($code);
        $node->parentNode->replaceChild($pi, $node);
    }
UseNode