mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 12:35:31 +00:00
38 lines
790 B
PHP
38 lines
790 B
PHP
<?php
|
|
namespace Wikia\PortableInfobox\Parser\Nodes;
|
|
|
|
class NodeGroup extends Node {
|
|
|
|
public function getData() {
|
|
if ( !isset( $this->data ) ) {
|
|
$this->data = [ 'value' => $this->getChildNodes() ];
|
|
}
|
|
|
|
return $this->data;
|
|
}
|
|
|
|
public function isEmpty() {
|
|
$data = $this->getData();
|
|
foreach ( $data[ 'value' ] as $elem ) {
|
|
if ( $elem[ 'type' ] != 'header' && !( $elem[ 'isEmpty' ] ) ) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function getSource() {
|
|
$data = $this->getData();
|
|
$result = [ ];
|
|
foreach ( $data[ 'value' ] as $item ) {
|
|
if ( isset( $item[ 'source' ] ) ) {
|
|
$source = !is_array( $item[ 'source' ] ) ? [ $item[ 'source' ] ] : $item[ 'source' ];
|
|
$result = array_merge( $result, $source );
|
|
}
|
|
}
|
|
|
|
return array_unique( $result );
|
|
}
|
|
}
|