/** * Visits a media node * * @param MediaNode $node The node * @param VisitorArguments $arguments The arguments * @return MediaNode|null */ public function visitMedia(MediaNode $node, VisitorArguments $arguments) { $node->accept($this); $arguments->visitDeeper = false; if (!count($node->rules)) { return null; } return $node; }
/** * Compiles the node * * @param Context $context The context * @param array|null $arguments Array of arguments * @param boolean|null $important Important flag * @return RulesetNode */ public function compile(Context $context, $arguments = null, $important = null) { if (!$context->mediaBlocks) { $context->mediaBlocks = []; $context->mediaPath = []; } $media = new MediaNode([], [], $this->index, $this->currentFileInfo); if ($this->debugInfo) { $this->rules[0]->debugInfo = $this->debugInfo; $media->debugInfo = $this->debugInfo; } $strictMathBypass = false; if (!$context->strictMath) { $strictMathBypass = true; $context->strictMath = true; } try { $media->features = $this->features->compile($context); } catch (Exception $e) { // empty on purpose } if ($strictMathBypass) { $context->strictMath = false; } $context->mediaPath[] = $media; $context->mediaBlocks[] = $media; $this->rules[0]->functionRegistry = isset($context->frames[0]) && $context->frames[0]->functionRegistry ? $context->frames[0]->functionRegistry->inherit() : $context->getFunctionRegistry()->inherit(); array_unshift($context->frames, $this->rules[0]); $media->rules = [$this->rules[0]->compile($context)]; array_shift($context->frames); array_pop($context->mediaPath); return count($context->mediaPath) == 0 ? $media->compileTop($context) : $media->compileNested($context); }
/** * @covers getType */ public function testGetType() { $d = new MediaNode(['black']); $this->assertEquals('Media', $d->getType()); }