Example #1
0
 /**
  * Returns the media inclusion tag contained in the given template.
  *
  * @param TemplateTag $template The template to search the media file tag in.
  *
  * @return UmgtMediaInclusionTag The media file inclusion tag.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 05.06.2010<br />
  */
 protected function &getIcon(TemplateTag $template)
 {
     foreach ($template->getChildren() as &$child) {
         if ($child instanceof UmgtMediaInclusionTag) {
             return $child;
         }
     }
     return null;
 }
Example #2
0
 /**
  * Test relocation of DOM nodes from included template into current node.
  */
 public function testDomRelocation()
 {
     $tag = new TemplateTag();
     $tag->setContent('<core:appendnode namespace="' . __NAMESPACE__ . '\\templates" template="include_simple" />');
     $tag->onParseTime();
     $tag->onAfterAppend();
     $children = $tag->getChildren();
     // including append node tag we've got three child nodes
     $this->assertCount(3, $children);
     $keys = array_keys($children);
     $this->assertInstanceOf(Template::class, $children[$keys[1]]);
     $this->assertInstanceOf(PlaceHolder::class, $children[$keys[2]]);
     // test whether the nodes have been re-referenced and not copied
     $appendNodeTag =& $children[$keys[0]];
     $appendNodeChildren = $appendNodeTag->getChildren();
     $innerKeys = array_keys($appendNodeChildren);
     $this->assertEquals(spl_object_hash($children[$keys[1]]), spl_object_hash($appendNodeChildren[$innerKeys[0]]));
     $this->assertEquals(spl_object_hash($children[$keys[2]]), spl_object_hash($appendNodeChildren[$innerKeys[1]]));
 }
Example #3
0
 /**
  * Test whether 1st expressions matches and document is *not* overwritten by second.
  */
 public function testExtractExpressionTags2()
 {
     $property = new ReflectionProperty(Document::class, 'knownExpressions');
     $property->setAccessible(true);
     // inject special conditions that apply for this
     $original = $property->getValue(null);
     $property->setValue(null, [TestTemplateExpressionOne::class, TestTemplateExpressionTwo::class]);
     // setup template
     $doc = new TemplateTag();
     $doc->setContent('${specialExpression1}|${specialExpression2}');
     $doc->onParseTime();
     $doc->onAfterAppend();
     $children = $doc->getChildren();
     $this->assertCount(2, $children);
     $this->assertEquals(TestTemplateExpressionOne::class, $children[array_keys($children)[0]]->getAttribute('expression'));
     // reset to original setup
     $property->setValue(null, $original);
 }