Ejemplo n.º 1
0
 public function chunk(Element $element)
 {
     $size = $element->getAttribute('data-size')->getValue();
     $chunks = array_map(function ($chunk) {
         return new ListModel($chunk);
     }, array_chunk($this->item, $size));
     return $chunks;
 }
Ejemplo n.º 2
0
 public function popElement()
 {
     if ($this->nextElement->getName() != $this->element->getName()) {
         throw new \Exception("Unmatched elements: {$this->element->getName()} and {$this->nextElement->getName()}");
     }
     $this->element->setHasClosingTag(true);
     $this->element = $this->element->getParent();
     $this->reset();
 }
Ejemplo n.º 3
0
 private function printElement(Element $node)
 {
     $out = '<' . $node->getName();
     foreach ($node->getAttributes() as $attribute) {
         $out .= ' ' . $attribute->getName();
         if ($attribute->getValue() !== null) {
             $quotes = $this->printQuotes($attribute->getQuoting());
             $out .= '=' . $quotes . $attribute->getValue() . $quotes;
         }
     }
     if (!$node->getChildren()->isEmpty() || $node->hasClosingTag()) {
         return $out . '>' . $this->printNodes($node->getChildren()) . '</' . $node->getName() . '>';
     } else {
         return $out . '/>';
     }
 }
Ejemplo n.º 4
0
 private function wrapAsset(Element $element, $attributeName)
 {
     $attribute = $element->getAttribute($attributeName);
     if (!$attribute) {
         return;
     }
     $url = Url::fromString($attribute->getValue());
     if ($url->isAbsolute()) {
         return;
     }
     $path = $url->getPath();
     $path->insertAll($this->path->slice(0, -1), 0);
     $url->setPath($path);
     $element->setAttribute($attributeName, $url->toString());
 }
 private function thenTheFootShouldBe($string)
 {
     $printer = new Printer();
     $footerContent = $printer->printNodes($this->dom->findChildElement('html')->findChildElement('body')->findChildElement('footer')->getChildren());
     $this->assertEquals($string, $footerContent);
 }
Ejemplo n.º 6
0
 private function getPropertyName(Element $element)
 {
     return $element->getAttribute('property')->getValue();
 }
Ejemplo n.º 7
0
 private function copyChildren(Element $copy)
 {
     foreach ($this->children as $child) {
         if ($child instanceof Element) {
             $copy->getChildren()->append($child->copy());
         } else {
             if ($child instanceof Text) {
                 $copy->getChildren()->append(new Text($child->getText()));
             }
         }
     }
 }