2015-04-27 14:05:31 +00:00
|
|
|
<?php
|
|
|
|
namespace Wikia\PortableInfobox\Parser\Nodes;
|
|
|
|
|
|
|
|
class NodeSet extends Node {
|
|
|
|
|
|
|
|
public function getData() {
|
2015-06-10 09:28:33 +00:00
|
|
|
if ( !isset( $this->data ) ) {
|
2015-06-11 09:34:28 +00:00
|
|
|
$this->data = [ 'value' => $this->getDataForChildren() ];
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|
2015-06-10 09:28:33 +00:00
|
|
|
|
|
|
|
return $this->data;
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|
|
|
|
|
2015-06-11 09:34:28 +00:00
|
|
|
public function getRenderData() {
|
|
|
|
return [
|
|
|
|
'type' => $this->getType(),
|
|
|
|
'data' => [
|
2015-06-12 13:43:37 +00:00
|
|
|
'value' => array_map(
|
|
|
|
function ( Node $item ) {
|
|
|
|
return $item->getRenderData();
|
|
|
|
},
|
|
|
|
$this->getChildNodes()
|
|
|
|
)
|
|
|
|
],
|
2015-06-11 09:34:28 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-06-10 09:28:33 +00:00
|
|
|
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() ) {
|
2015-04-27 14:05:31 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-06-10 09:28:33 +00:00
|
|
|
|
2015-04-27 14:05:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-06-10 15:19:40 +00:00
|
|
|
|
|
|
|
public function getSource() {
|
2015-06-11 09:48:32 +00:00
|
|
|
return $this->getSourceForChildren();
|
2015-06-10 15:19:40 +00:00
|
|
|
}
|
2015-04-27 14:05:31 +00:00
|
|
|
}
|