Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * @covers getType
  */
 public function testGetType()
 {
     $d = new MediaNode(['black']);
     $this->assertEquals('Media', $d->getType());
 }