Skip to content

Commit

Permalink
Update TV:
Browse files Browse the repository at this point in the history
- update indexProgrammes() method
  • Loading branch information
webeweb committed Jul 30, 2019
1 parent bbb8edd commit dd325b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/Model/Tv.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,25 @@ public function getSourceInfoURL() {
}

/**
* Indexes the programmes.
* Indexes the programmes by channel.
*
* @return void
* @return Tv Returns this TV.
*/
public function indexProgrammes() {
public function indexProgrammesByChannel() {

$this->sortChannels();
$this->sortProgrammes();

$channels = $this->indexChannelsById();

/** @var Programme $current */
foreach ($this->programmes as $current) {

$channel = $this->getChannelById($current->getChannel());
if (null !== $channel) {
$channel->addProgramme($current);
if (true === array_key_exists($current->getChannel(), $channels)) {
$channels[$current->getChannel()]->addProgramme($current);
}
}

return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public static function parseTv(DOMNode $domNode) {
ParserHelper::parseChildNodes($domNode, "channel", $model);
ParserHelper::parseChildNodes($domNode, "programme", $model);

$model->indexProgrammes();
$model->indexProgrammesByChannel();

return $model;
}
Expand Down

0 comments on commit dd325b6

Please sign in to comment.