예제 #1
0
파일: Element.php 프로젝트: ymnl007/Clerk
 /**
  * @param DOMNode        $node
  * @param ReferenceTable $table
  */
 public function next(DOMNode $node, ReferenceTable &$table)
 {
     foreach ($node->childNodes as $child) {
         /*
          * Text
          */
         if ($child instanceof DOMTEXT) {
             $table->appendContentByNode($child);
         } elseif ($child instanceof DOMElement) {
             /*
              * Attributes
              */
             foreach ($child->attributes as $attribute) {
                 $parser = AttributeParserFactory::create($attribute->name, $this->sheet);
                 if ($parser) {
                     $parser->parse($attribute, $table);
                 }
             }
             // Get the element parser based on the node name
             $parser = ElementParserFactory::create($child->nodeName, $this->sheet);
             // It's possible a parser does not exist
             // That means it's probably not very interesting
             // to parse that element
             if ($parser) {
                 $parser->parse($child, $table);
             } else {
                 $this->next($child, $table);
             }
         }
     }
 }
예제 #2
0
 public function test_factory_returns_right_element()
 {
     $this->assertInstanceOf('Maatwebsite\\Clerk\\Excel\\Html\\Elements\\TrElement', ElementParserFactory::create('tr', $this->mockSheet()));
     $this->assertInstanceOf('Maatwebsite\\Clerk\\Excel\\Html\\Elements\\TdElement', ElementParserFactory::create('td', $this->mockSheet()));
     $this->assertInstanceOf('Maatwebsite\\Clerk\\Excel\\Html\\Elements\\ThElement', ElementParserFactory::create('th', $this->mockSheet()));
 }