mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 12:35:31 +00:00
51 lines
986 B
PHP
51 lines
986 B
PHP
<?php
|
|
namespace Wikia\PortableInfobox\Parser\Nodes;
|
|
|
|
class NodeInfobox extends Node {
|
|
|
|
protected $params;
|
|
|
|
public function getData() {
|
|
if ( !isset( $this->data ) ) {
|
|
$this->data = [ 'value' => $this->getDataForChildren() ];
|
|
}
|
|
|
|
return $this->data;
|
|
}
|
|
|
|
public function getRenderData() {
|
|
return array_map( function ( Node $item ) {
|
|
return $item->getRenderData();
|
|
}, array_filter( $this->getChildNodes(), function ( Node $item ) {
|
|
return !$item->isEmpty();
|
|
} ) );
|
|
}
|
|
|
|
public function isEmpty() {
|
|
/** @var Node $child */
|
|
foreach ( $this->getChildNodes() as $child ) {
|
|
if ( !$child->isEmpty() ) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function getParams() {
|
|
if ( !isset( $this->params ) ) {
|
|
$result = [ ];
|
|
foreach ( $this->xmlNode->attributes() as $k => $v ) {
|
|
$result[ $k ] = (string)$v;
|
|
}
|
|
$this->params = $result;
|
|
}
|
|
|
|
return $this->params;
|
|
}
|
|
|
|
public function getSource() {
|
|
return $this->getSourceForChildren();
|
|
}
|
|
}
|