+ Error on line 147
$currentSeason = !empty($this->show->season) ? $this->show->season : $this->show->available_video_seasons[0]->seasonNum ;
<?php
namespace cbs\app\digital\controllers\shows;
use cbs\core\blocks\components\EpisodesGuide;
use cbs\core\helpers\VideoHelper;
use cbs\core\lib\Platform;
use cbs\core\managers\VideosManager;
use cbs\core\models\show\ShowEpisodesModel;
use cbs\core\blocks\atoms\DropdownFilter;
use cbs\core\lib\Page;
use cbs\core\controllers\shows\ShowsComponentsControllerTrait;
use cbs\core\utils\Carousel;
use cbs\core\utils\Log;
use cbs\core\utils\ViewHelper;
use stdClass;
class ShowsEpisodesGuideController extends \cbs\core\controllers\shows\ShowsController
{
use ShowsComponentsControllerTrait;
protected $content;
protected $seasons;
protected $currentSeason;
protected $filter;
public function beforeRun($resource, $action)
{
parent::beforeRun($resource, $action);
try {
$this->fetchContent();
} catch (\Exception $e) {
Log::info($e->getMessage());
}
}
/**
* Generic about page for all shows
*
* @throws \Exception
*/
public function index()
{
Page::dw('EPISODES');
Page::section('Episodes');
Page::metaTags($this->show->title . ' Season ' . $this->currentSeason.' Episodes', $this->show->title . ', ' . ' Season ' . $this->currentSeason.' Episodes', 'Full list of episodes for season '.$this->currentSeason.' of '.$this->show->title.'. Stream and watch full episodes on CBS.');
$this->view->setJSBundle('show/episodesGuide.js');
$this->view->setCSSBundle('pages/showEpisodesGuide.css');
$this->buildEpisodesComponent();
}
/**
* @throws \Exception
*/
private function fetchContent()
{
$this->setVideoSectionIds();
# get full eps
$this->getFullEpisodes(VideoHelper::CONFIG_SHOW_HOME_CONFIG);
}
/**
* Build episodes component
*/
protected function buildEpisodesComponent()
{
if (!empty($this->content)) {
$episodesBlock = new EpisodesGuide();
$episodesBlock->setData($this->content);
$episodesBlock->setSeasons($this->seasons,$this->currentSeason);
$episodesBlock->setFilter($this->filter);
$this->pageVars->episodesBlock = $episodesBlock;
$this->view->render('pages/shows/episodes/main-page');
}
}
/**
* Parsing section ids for Full Episodes section & dynamic sections need to render in page
*/
private function setVideoSectionIds()
{
# this code (not api call) to run after Full Eps call to setup Clips grid sectionId
$m = new VideosManager($this->show->id);
$m->overridePlatform(Platform::PLATFORM_DESKTOP);
$m->setConfig(VideoHelper::CONFIG_SHOW_HOME_CONFIG);
$m->setPreviewMode();
$m->size = 1;
$resp = $m->getSectionByIndex();
if (!empty($resp['section_metadata'])) {
$this->sectionMetadata = $resp['section_metadata'];
}
if (!empty($resp)) {
$this->sectionIdEpisodes = $resp[0]->id;
$__sectionIds = $resp[1];
$pos = array_search($this->sectionIdEpisodes, $__sectionIds);
unset($__sectionIds[$pos]);
$this->sectionIds = $__sectionIds;
$this->pageVars->sectionIds = $this->sectionIds;
$this->pageVars->sectionIdEpisodes = $this->sectionIdEpisodes;
}
}
/**
* Get Full Episodes
* @param $config
*/
protected function getFullEpisodes($config)
{
$episodesPassThroughParams = [
'offset' => 0,
'limit' => 12,
];
if (!$this->excludeShowId) {
$episodesPassThroughParams['siteShowId'] = $this->show->id;
}
$currentSeason = null;
$seasonFilterBlock = null;
//Check for season param
if(isset($this->params['season'])){
$currentSeason = $this->params['season'];
}
if (isset($this->sectionMetadata[$this->sectionIdEpisodes])) {
$metadata = $this->sectionMetadata[$this->sectionIdEpisodes];
if (!empty($metadata['seasons_default']) && $currentSeason == null) {
$currentSeason = $metadata['seasons_default'];
}
if (!$currentSeason) {
$currentSeason = !empty($this->show->season) ? $this->show->season : $this->show->available_video_seasons[0]->seasonNum ;
}
$seasonFilters = [];
if ($metadata['display_seasons']) {
# seasons
$seasons = Carousel::getShowVideoSeasons($this->show);
foreach ($seasons as $idx=>$s) {
$seasonFilter = new stdClass();
$seasonFilter->title = $s['title'];
$seasonFilter->value = $s['season'];
$seasonFilter->url = CBSAPP_URL.'/shows/'.$this->configName.'/episodes/'.$s['season'].'/';
if($s['season'] == $currentSeason){
$seasonFilter->active = true;
}
array_push($seasonFilters, $seasonFilter);
}
// sorting seasons as cms directed
if (!empty($metadata['seasons_sort_order'])) {
$sortOrder = strtolower($metadata['seasons_sort_order']);
if (in_array($sortOrder, ['asc', 'desc'])) {
usort($seasonFilters, function ($a, $b) use ($sortOrder) {
if ($sortOrder == 'asc') {
return intval($a->value) - intval($b->value);
} else {
return intval($b->value) - intval($a->value);
}
});
}
}
$seasonFilterBlock = new DropdownFilter();
$seasonFilterBlock->setFilters($seasonFilters)
->setAARegion(self::SEASON_FILTER_TYPE);
$selectedFilterInd = array_search($currentSeason, array_column($seasonFilters, 'value'));
if ($selectedFilterInd !== false) {
$seasonFilterBlock->setSelectedInd($selectedFilterInd);
}
}
}
if ($currentSeason) {
$episodesPassThroughParams['seasonNum'] = $currentSeason;
}
$videoManager = new VideosManager($this->show->id);
$videoManager->setConfig($config);
$videoManager->setCustomParams(['seasonNum' => $currentSeason]);
$videoManager->setPassThroughParams($episodesPassThroughParams);
//Default season size
$seasonSize = 14;
foreach ($this->show->available_video_seasons as $season) {
if($season->seasonNum == $currentSeason){
$seasonSize = $season->totalCount;
break;
}
}
$resp = $videoManager->getLatestVideos(0,$seasonSize);
if(empty($resp)){
ViewHelper::force404();
}
if ($resp !== false) {
if(!empty($seasonFilterBlock) && !empty($seasonFilters)) {
if(empty($selectedFilterInd)){
$selectedFilterInd = 0;
}
$aaSeasonFilterLink = $seasonFilterBlock->generateFilterAALink($resp->title, $seasonFilters[$selectedFilterInd]->title);
$seasonFilterBlock->setFilterTitle(strtolower($resp->title))
->setFilterType(self::SEASON_FILTER_TYPE)
->setAALink($aaSeasonFilterLink)
->setFiltersAALink();
}
$episodesModel = new ShowEpisodesModel();
$this->content = $episodesModel->setData($resp->data);
$this->filter = $seasonFilterBlock;
$this->seasons = $seasonFilters;
$this->currentSeason = $currentSeason;
$this->pageVars->footer->setEpisodesData($this->content);
$this->pageVars->footer->googleEpisodes = true;
}
}
}
* Stack Trace...
- /usr/local/deploy/mvc-deploys/mvc-release/htdocs/index.php(168) calling run()
- /usr/local/deploy/mvc-deploys/mvc-release/vendor/viacomcbs/doophp/src/app/DooWebApp.php(34) calling routeTo()
- /usr/local/deploy/mvc-deploys/mvc-release/vendor/viacomcbs/doophp/src/app/DooWebApp.php(122) calling beforeRun()
- /usr/local/deploy/mvc-deploys/mvc-release/src/controllers/shows/ShowsEpisodesGuideController.php(32) calling fetchContent()
- /usr/local/deploy/mvc-deploys/mvc-release/src/controllers/shows/ShowsEpisodesGuideController.php(64) calling getFullEpisodes()
object(DooConfig)#11 (22) {
["AUTOLOAD"] => NULL
["SITE_PATH"] => string(42) "/usr/local/deploy/mvc-deploys/mvc-release/"
["PROTECTED_FOLDER"] => string(46) "/usr/local/deploy/mvc-deploys/mvc-release/src/"
["BASE_PATH"] => string(70) "/usr/local/deploy/mvc-deploys/mvc-release/vendor/viacomcbs/doophp/src/"
["LOG_PATH"] => NULL
["APP_URL"] => string(24) "http://test-www.cbs.com/"
["SUBFOLDER"] => string(1) "/"
["APP_MODE"] => string(3) "dev"
["AUTOROUTE"] => bool(false)
["DEBUG_ENABLED"] => bool(true)
["ERROR_404_DOCUMENT"] => NULL
["ERROR_404_ROUTE"] => string(44) "/error/?%2Fshows%2Ftony_awards%2Fepisodes%2F"
["CACHE_PATH"] => NULL
["AUTO_VIEW_RENDER_PATH"] => string(21) "/shows/:slug/episodes"
["MEMCACHE"] => NULL
["TEMPLATE_ENGINE"] => string(7) "DooView"
["TEMPLATE_SHOW_COMMENT"] => NULL
["TEMPLATE_ALLOW_PHP"] => NULL
["TEMPLATE_COMPILE_ALWAYS"] => NULL
["TEMPLATE_GLOBAL_TAGS"] => NULL
["MODULES"] => NULL
["APP_NAMESPACE_ID"] => NULL
}
$_COOKIE Variables
array(0) {
}