PortableInfobox/services/Parser/Nodes/NodeSet.php

41 lines
814 B
PHP
Raw Normal View History

<?php
namespace Wikia\PortableInfobox\Parser\Nodes;
class NodeSet extends Node {
public function getData() {
if ( !isset( $this->data ) ) {
2015-06-11 09:34:28 +00:00
$this->data = [ 'value' => $this->getDataForChildren() ];
}
return $this->data;
}
2015-06-11 09:34:28 +00:00
public function getRenderData() {
return [
'type' => $this->getType(),
'data' => [
'value' => array_map( function ( Node $item ) {
return $item->getRenderData();
}, $this->getChildNodes() ) ],
'isEmpty' => $this->isEmpty(),
'source' => $this->getSource()
];
}
public function isEmpty() {
2015-06-11 09:34:28 +00:00
/** @var Node $item */
foreach ( $this->getChildNodes() as $item ) {
if ( !$item->isType( 'header' ) && !$item->isEmpty() ) {
return false;
}
}
return true;
}
public function getSource() {
return $this->getSourceForChildren();
}
}