2023-04-05 14:44:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Shikiryu\SRSS;
|
|
|
|
|
|
|
|
use DOMDocument;
|
2023-04-06 00:38:26 +02:00
|
|
|
use DOMNodeList;
|
2023-04-05 14:44:57 +02:00
|
|
|
use DOMXPath;
|
|
|
|
use Iterator;
|
2023-04-06 00:38:26 +02:00
|
|
|
use ReturnTypeWillChange;
|
|
|
|
use Shikiryu\SRSS\Entity\Channel;
|
|
|
|
use Shikiryu\SRSS\Entity\Channel\Image;
|
|
|
|
use Shikiryu\SRSS\Entity\Item;
|
2023-04-05 14:44:57 +02:00
|
|
|
|
|
|
|
class SRSS extends DomDocument implements Iterator
|
|
|
|
{
|
2023-04-06 00:38:26 +02:00
|
|
|
protected DOMXPath $xpath; // xpath engine
|
|
|
|
protected array $items; // array of SRSSItems
|
2023-04-05 14:44:57 +02:00
|
|
|
protected $attr; // array of RSS attributes
|
|
|
|
private $position; // Iterator position
|
|
|
|
|
2023-04-06 00:38:26 +02:00
|
|
|
private Channel $channel;
|
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
// lists of possible attributes for RSS
|
|
|
|
protected $possibleAttr = [
|
|
|
|
'title' => 'nohtml',
|
|
|
|
'link' => 'link',
|
|
|
|
'description' => 'html',
|
|
|
|
'language' => '',
|
|
|
|
//'language' => 'lang',
|
|
|
|
'copyright' => 'nohtml',
|
|
|
|
'pubDate' => 'date',
|
|
|
|
'lastBuildDate' => 'date',
|
|
|
|
'category' => 'nohtml',
|
|
|
|
'docs' => 'link',
|
|
|
|
'cloud' => '',
|
|
|
|
'generator' => 'nohtml',
|
|
|
|
'managingEditor' => 'email',
|
|
|
|
'webMaster' => 'email',
|
|
|
|
'ttl' => 'int',
|
|
|
|
'image' => '',
|
|
|
|
'rating' => 'nohtml',
|
|
|
|
//'textInput' => '',
|
|
|
|
'skipHours' => 'hour',
|
|
|
|
'skipDays' => 'day',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
libxml_use_internal_errors(true);
|
|
|
|
parent::__construct();
|
|
|
|
$this->xpath = new DOMXpath($this);
|
2023-04-06 00:38:26 +02:00
|
|
|
$this->attr = [];
|
|
|
|
$this->items = [];
|
2023-04-05 14:44:57 +02:00
|
|
|
$this->position = 0;
|
|
|
|
$this->formatOutput = true;
|
|
|
|
$this->preserveWhiteSpace = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
* manage of libxml errors
|
|
|
|
*/
|
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
foreach (libxml_get_errors() as $error) {
|
|
|
|
error_log($error->message, 3, 'error.log');
|
|
|
|
}
|
|
|
|
libxml_clear_errors();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-04-06 00:38:26 +02:00
|
|
|
* @param string $link url of the rss
|
2023-04-05 14:44:57 +02:00
|
|
|
* @throws SRSSException
|
|
|
|
* @return SRSS
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public static function read(string $link): SRSS
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
$doc = new SRSS;
|
2023-04-06 00:38:26 +02:00
|
|
|
if(@$doc->load($link)) { // We don't want the warning in case of bad XML. Let's manage it with an exception.
|
2023-04-05 14:44:57 +02:00
|
|
|
$channel = $doc->getElementsByTagName('channel');
|
|
|
|
if($channel->length == 1){ // Good URL and good RSS
|
|
|
|
$doc->_loadAttributes(); // loading channel properties
|
|
|
|
$doc->getItems(); // loading all items
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
return $doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new SRSSException('invalid file '.$link);
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new SRSSException('Can not open file '.$link);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return SRSS
|
2023-04-06 00:38:26 +02:00
|
|
|
* @throws \DOMException
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
|
|
|
public static function create()
|
|
|
|
{
|
|
|
|
$doc = new SRSS;
|
|
|
|
$root = $doc->createElement('rss');
|
|
|
|
$root->setAttribute('version', '2.0');
|
|
|
|
$channel = $doc->createElement('channel');
|
|
|
|
$root->appendChild($channel);
|
|
|
|
$doc->appendChild($root);
|
|
|
|
$doc->encoding = "UTF-8";
|
|
|
|
$doc->generator = 'Shikiryu RSS';
|
|
|
|
// $docs = 'http://www.scriptol.fr/rss/RSS-2.0.html';
|
2023-04-06 00:38:26 +02:00
|
|
|
$doc->channel = new Channel();
|
|
|
|
$doc->items = [];
|
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
return $doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of "image"'s channel attributes
|
|
|
|
* @return string|array
|
2023-04-06 00:38:26 +02:00
|
|
|
* TODO
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
|
|
|
public function image()
|
|
|
|
{
|
|
|
|
$args = func_get_args();
|
2023-04-06 00:38:26 +02:00
|
|
|
if (func_num_args() == 0) {
|
|
|
|
$args[0] = 'url';
|
|
|
|
}
|
2023-04-05 14:44:57 +02:00
|
|
|
$img = $this->xpath->query('//channel/image');
|
2023-04-06 00:38:26 +02:00
|
|
|
if($img->length != 1) { // <image> is not in channel
|
|
|
|
return null;
|
|
|
|
}
|
2023-04-05 14:44:57 +02:00
|
|
|
$img = $img->item(0);
|
2023-04-06 00:38:26 +02:00
|
|
|
$r = [];
|
|
|
|
foreach($img->childNodes as $child) {
|
|
|
|
if($child->nodeType == XML_ELEMENT_NODE && in_array($child->nodeName, $args)) {
|
2023-04-05 14:44:57 +02:00
|
|
|
$r[$child->nodeName] = $child->nodeValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (func_num_args() > 1) ? $r : $r[$args[0]];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setter of "image"'s channel attributes
|
|
|
|
* @param $url string picture's url
|
|
|
|
* @param $title string picture's title
|
|
|
|
* @param $link string link on the picture
|
|
|
|
* @param $width int width
|
|
|
|
* @param $height int height
|
|
|
|
* @param $description string description
|
2023-04-06 00:38:26 +02:00
|
|
|
* TODO
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
|
|
|
public function setImage($url, $title, $link, $width = 0, $height = 0, $description = '')
|
|
|
|
{
|
|
|
|
$channel = $this->_getChannel();
|
|
|
|
$array = [];
|
|
|
|
$url = SRSSTools::checkLink($url);
|
|
|
|
$array['url'] = $url;
|
|
|
|
$title = SRSSTools::noHTML($title);
|
|
|
|
$array['title'] = $title;
|
|
|
|
$link = SRSSTools::checkLink($link);
|
|
|
|
$array['link'] = $link;
|
|
|
|
if($width != 0)
|
|
|
|
{
|
|
|
|
$width = SRSSTools::checkInt($width);
|
|
|
|
$array['width'] = $width;
|
|
|
|
}
|
|
|
|
if($height != 0)
|
|
|
|
{
|
|
|
|
$height = SRSSTools::checkInt($height);
|
|
|
|
$array['height'] = $height;
|
|
|
|
}
|
|
|
|
if($description != 0)
|
|
|
|
{
|
|
|
|
$description = SRSSTools::noHTML($description);
|
|
|
|
$array['description'] = $description;
|
|
|
|
}
|
|
|
|
if($this->image == null)
|
|
|
|
{
|
|
|
|
$node = $this->createElement('image');
|
|
|
|
$urlNode = $this->createElement('url', $url);
|
|
|
|
$titleNode = $this->createElement('title', $title);
|
|
|
|
$linkNode = $this->createElement('link', $link);
|
|
|
|
$node->appendChild($urlNode);
|
|
|
|
$node->appendChild($titleNode);
|
|
|
|
$node->appendChild($linkNode);
|
|
|
|
if($width != 0)
|
|
|
|
{
|
|
|
|
$widthNode = $this->createElement('width', $width);
|
|
|
|
$node->appendChild($widthNode);
|
|
|
|
}
|
|
|
|
if($height != 0)
|
|
|
|
{
|
|
|
|
$heightNode = $this->createElement('height', $height);
|
|
|
|
$node->appendChild($heightNode);
|
|
|
|
}
|
|
|
|
if($description != '')
|
|
|
|
{
|
|
|
|
$descNode = $this->createElement('description', $description);
|
|
|
|
$node->appendChild($descNode);
|
|
|
|
}
|
|
|
|
$channel->appendChild($node);
|
|
|
|
}
|
|
|
|
$this->attr['image'] = $array;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setter of "cloud"'s channel attributes
|
|
|
|
* @param $domain string domain
|
|
|
|
* @param $port int port
|
|
|
|
* @param $path string path
|
|
|
|
* @param $registerProcedure string register procedure
|
|
|
|
* @param $protocol string protocol
|
2023-04-06 00:38:26 +02:00
|
|
|
* TODO
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
|
|
|
public function setCloud($domain, $port, $path, $registerProcedure, $protocol)
|
|
|
|
{
|
|
|
|
$channel = $this->_getChannel();
|
|
|
|
$array = array();
|
|
|
|
$domain = SRSSTools::noHTML($domain);
|
|
|
|
$array['domain'] = $domain;
|
|
|
|
$port = SRSSTools::checkInt($port);
|
|
|
|
$array['port'] = $port;
|
|
|
|
$path = SRSSTools::noHTML($path);
|
|
|
|
$array['path'] = $path;
|
|
|
|
$registerProcedure = SRSSTools::noHTML($registerProcedure);
|
|
|
|
$array['registerProcedure'] = $registerProcedure;
|
|
|
|
$protocol = SRSSTools::noHTML($protocol);
|
|
|
|
$array['protocol'] = $protocol;
|
|
|
|
if($this->cloud == null)
|
|
|
|
{
|
|
|
|
$node = $this->createElement('cloud');
|
|
|
|
$node->setAttribute('domain', $domain);
|
|
|
|
$node->setAttribute('port', $port);
|
|
|
|
$node->setAttribute('path', $path);
|
|
|
|
$node->setAttribute('registerProcedure', $registerProcedure);
|
|
|
|
$node->setAttribute('protocol', $protocol);
|
|
|
|
$channel->appendChild($node);
|
|
|
|
}
|
|
|
|
$this->attr['cloud'] = $array;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* check if current RSS is a valid one (based on specifications)
|
|
|
|
* @return bool
|
2023-04-06 00:38:26 +02:00
|
|
|
* TODO use required
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
|
|
|
public function isValid()
|
|
|
|
{
|
|
|
|
$valid = true;
|
|
|
|
$items = $this->getItems();
|
2023-04-06 00:38:26 +02:00
|
|
|
$invalidItems = [];
|
2023-04-05 14:44:57 +02:00
|
|
|
$i = 1;
|
|
|
|
foreach($items as $item){
|
|
|
|
if($item->isValid() === false){
|
|
|
|
$invalidItems[] = $i;
|
|
|
|
$valid = false;
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
return ($valid && $this->title != null && $this->link != null && $this->description != null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of current RSS channel
|
2023-04-06 00:38:26 +02:00
|
|
|
* @return \DOMNode
|
2023-04-05 14:44:57 +02:00
|
|
|
* @throws SRSSException
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
private function _getChannel(): \DOMNode
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
$channel = $this->getElementsByTagName('channel');
|
2023-04-06 00:38:26 +02:00
|
|
|
if($channel->length != 1) {
|
|
|
|
throw new SRSSException('channel node not created, or too many channel nodes');
|
|
|
|
}
|
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
return $channel->item(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $name
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function __isset($name)
|
|
|
|
{
|
|
|
|
return isset($this->attr[$name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setter of others attributes
|
|
|
|
* @param $name
|
|
|
|
* @param $val
|
|
|
|
* @throws SRSSException
|
|
|
|
*/
|
|
|
|
public function __set($name, $val)
|
|
|
|
{
|
|
|
|
$channel = $this->_getChannel();
|
|
|
|
if(array_key_exists($name, $this->possibleAttr)){
|
|
|
|
$flag = $this->possibleAttr[$name];
|
|
|
|
$val = SRSSTools::check($val, $flag);
|
|
|
|
if(!empty($val)){
|
|
|
|
if($this->$name == null){
|
|
|
|
$node = $this->createElement($name, $val);
|
|
|
|
$channel->appendChild($node);
|
|
|
|
}
|
|
|
|
$this->attr[$name] = $val;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
throw new SRSSException($name.' is not a possible item');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of others attributes
|
|
|
|
* @param $name
|
|
|
|
* @return null|string
|
|
|
|
* @throws SRSSException
|
|
|
|
*/
|
|
|
|
public function __get($name)
|
|
|
|
{
|
2023-04-06 00:38:26 +02:00
|
|
|
if (isset($this->channel->{$name})) {
|
|
|
|
return $this->channel->{$name};
|
|
|
|
}
|
2023-04-05 14:44:57 +02:00
|
|
|
// $channel = $this->_getChannel();
|
|
|
|
if(array_key_exists($name, $this->possibleAttr)){
|
|
|
|
$tmp = $this->xpath->query('//channel/'.$name);
|
2023-04-06 00:38:26 +02:00
|
|
|
if($tmp->length != 1) {
|
|
|
|
return null;
|
|
|
|
}
|
2023-04-05 14:44:57 +02:00
|
|
|
return $tmp->item(0)->nodeValue;
|
|
|
|
}
|
2023-04-06 00:38:26 +02:00
|
|
|
|
|
|
|
throw new SRSSException($name.' is not a possible value.');
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add a SRSS Item as an item into current RSS as first item
|
|
|
|
* @param SRSSItem $item
|
|
|
|
*/
|
|
|
|
public function addItemBefore(SRSSItem $item)
|
|
|
|
{
|
|
|
|
$node = $this->importNode($item->getItem(), true);
|
|
|
|
$items = $this->getElementsByTagName('item');
|
|
|
|
if($items->length != 0){
|
|
|
|
$firstNode = $items->item(0);
|
|
|
|
if($firstNode != null)
|
|
|
|
$firstNode->parentNode->insertBefore($node, $firstNode);
|
|
|
|
else
|
|
|
|
$this->addItem($item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$this->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add a SRSS Item as an item into current RSS
|
|
|
|
* @param SRSSItem $item
|
|
|
|
*/
|
|
|
|
public function addItem(SRSSItem $item)
|
|
|
|
{
|
|
|
|
$node = $this->importNode($item->getItem(), true);
|
|
|
|
$channel = $this->_getChannel();
|
|
|
|
$channel->appendChild($node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* rewind from Iterator
|
|
|
|
*/
|
|
|
|
public function rewind() {
|
|
|
|
$this->position = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* current from Iterator
|
|
|
|
*/
|
|
|
|
public function current() {
|
|
|
|
return $this->items[$this->position];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* key from Iterator
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
#[ReturnTypeWillChange] public function key(): int
|
|
|
|
{
|
2023-04-05 14:44:57 +02:00
|
|
|
return $this->position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* next from Iterator
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
#[ReturnTypeWillChange] public function next(): void
|
|
|
|
{
|
2023-04-05 14:44:57 +02:00
|
|
|
++$this->position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* valid from Iterator
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
#[ReturnTypeWillChange] public function valid(): bool
|
|
|
|
{
|
2023-04-05 14:44:57 +02:00
|
|
|
return isset($this->items[$this->position]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of 1st item
|
2023-04-06 00:38:26 +02:00
|
|
|
* @return Item
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public function getFirst(): ?Item
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
return $this->getItem(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of last item
|
2023-04-06 00:38:26 +02:00
|
|
|
* @return Item
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public function getLast(): Item
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
$items = $this->getItems();
|
2023-04-06 00:38:26 +02:00
|
|
|
return $items[array_key_last($items)];
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of an item
|
|
|
|
* @param $i int
|
2023-04-06 00:38:26 +02:00
|
|
|
*
|
|
|
|
* @return Item|null
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public function getItem(int $i): ?Item
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
|
|
|
$i--;
|
2023-04-06 00:38:26 +02:00
|
|
|
return $this->items[$i] ?? null;
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getter of all items
|
2023-04-06 00:38:26 +02:00
|
|
|
* @return Item[]
|
2023-04-05 14:44:57 +02:00
|
|
|
* @throws SRSSException
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public function getItems(): array
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
2023-04-06 00:38:26 +02:00
|
|
|
if (!empty($this->items)) {
|
|
|
|
return $this->items;
|
|
|
|
}
|
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
$channel = $this->_getChannel();
|
2023-04-06 00:38:26 +02:00
|
|
|
/** @var DOMNodeList $items */
|
|
|
|
$items = $channel->getElementsByTagName('item');
|
|
|
|
$length = $items->length;
|
2023-04-05 14:44:57 +02:00
|
|
|
$this->items = [];
|
2023-04-06 00:38:26 +02:00
|
|
|
if ($length > 0) {
|
|
|
|
for($i = 0; $i < $length; $i++) {
|
|
|
|
$this->items[$i] = SRSSItem::read($items->item($i));
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
}
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
return $this->items;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* display XML
|
|
|
|
* see DomDocument's docs
|
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public function show(): bool|string
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
2023-04-06 00:38:26 +02:00
|
|
|
// TODO build
|
2023-04-05 14:44:57 +02:00
|
|
|
return $this->saveXml();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* putting all RSS attributes into the object
|
2023-04-06 00:38:26 +02:00
|
|
|
* @throws SRSSException
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
private function _loadAttributes(): void
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
2023-04-06 00:38:26 +02:00
|
|
|
$node_channel = $this->_getChannel();
|
|
|
|
$this->channel = new Channel();
|
|
|
|
|
|
|
|
foreach($node_channel->childNodes as $child) {
|
|
|
|
if($child->nodeType == XML_ELEMENT_NODE && $child->nodeName !== 'item') {
|
|
|
|
if($child->nodeName == 'image') {
|
|
|
|
$image = new Image();
|
|
|
|
foreach($child->childNodes as $children) {
|
|
|
|
if($children->nodeType == XML_ELEMENT_NODE) {
|
|
|
|
$image->{$child->nodeName} = $children->nodeValue;
|
|
|
|
}
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
2023-04-06 00:38:26 +02:00
|
|
|
$this->channel->image = $image;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->channel->{$child->nodeName} = $child->nodeValue;
|
2023-04-05 14:44:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* transform current object into an array
|
|
|
|
* @return array
|
2023-04-06 00:38:26 +02:00
|
|
|
* @throws SRSSException
|
2023-04-05 14:44:57 +02:00
|
|
|
*/
|
2023-04-06 00:38:26 +02:00
|
|
|
public function toArray(): array
|
2023-04-05 14:44:57 +02:00
|
|
|
{
|
2023-04-06 00:38:26 +02:00
|
|
|
$doc = $this->channel->toArray();
|
|
|
|
|
|
|
|
foreach($this->getItems() as $item) {
|
2023-04-05 14:44:57 +02:00
|
|
|
$doc['items'][] = $item->toArray();
|
|
|
|
}
|
2023-04-06 00:38:26 +02:00
|
|
|
|
2023-04-05 14:44:57 +02:00
|
|
|
return $doc;
|
|
|
|
}
|
|
|
|
}
|