~xibo-maintainers/xibo/release21

« back to all changes in this revision

Viewing changes to lib/Widget/SubPlaylist.php

  • Committer: GitHub
  • Author(s): Dan Garner
  • Date: 2019-09-24 08:37:08 UTC
  • mfrom: (771.2.1)
  • Revision ID: git-v1:e2731cede54d8ebede5dabc3077fdbe973953adc
Merge pull request #673 from dasgarner/release21

Do not save inside sub playlists recursive function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
310
310
     * @param int $parentWidgetId this tracks the top level widgetId
311
311
     * @return Widget[] $widgets
312
312
     * @throws \Xibo\Exception\NotFoundException
 
313
     * @throws \Xibo\Exception\InvalidArgumentException
313
314
     */
314
315
    public function getSubPlaylistResolvedWidgets($parentWidgetId = 0)
315
316
    {
340
341
            $playlist = $this->playlistFactory->getById($playlistId)->setModuleFactory($this->moduleFactory);
341
342
            $expanded = $playlist->expandWidgets($parentWidgetId);
342
343
            $countExpanded = count($expanded);
343
 
            $playlistEnableStat = $playlist->enableStat;
344
 
 
345
 
            if (($playlistEnableStat === null) || ($playlistEnableStat === "")) {
346
 
                $playlistEnableStat = $this->getConfig()->getSetting('PLAYLIST_STATS_ENABLED_DEFAULT');
347
 
            }
348
 
 
349
 
            // Go through widgets assigned to this Playlist, if their enableStat is set to Inherit, then change that option according to the Playlist enableStat value.
 
344
 
 
345
            // Handle proof of play settings
 
346
            // -----------------------------
 
347
            // Go through widgets assigned to this Playlist, if their enableStat is set to Inherit alter that option
 
348
            // in memory for this widget.
 
349
            // this is not a saved change, we assess this every time
 
350
            $playlistEnableStat = empty($playlist->enableStat)
 
351
                ? $this->getConfig()->getSetting('PLAYLIST_STATS_ENABLED_DEFAULT')
 
352
                : $playlist->enableStat;
 
353
 
350
354
            foreach ($expanded as $subPlaylistWidget) {
351
355
 
352
 
                $subPlaylistWidgetEnableStat = $subPlaylistWidget->getOptionValue('enableStat', $this->getConfig()->getSetting('WIDGET_STATS_ENABLED_DEFAULT'));
 
356
                $subPlaylistWidgetEnableStat = $subPlaylistWidget->getOptionValue('enableStat',
 
357
                    $this->getConfig()->getSetting('WIDGET_STATS_ENABLED_DEFAULT')
 
358
                );
353
359
 
354
360
                if ($subPlaylistWidgetEnableStat == 'Inherit') {
 
361
                    $this->getLog()->debug('For widget ID ' . $subPlaylistWidget->widgetId . ' enableStat was Inherit, changed to Playlist enableStat value - ' . $playlistEnableStat);
355
362
                    $subPlaylistWidget->setOptionValue('enableStat', 'attrib', $playlistEnableStat);
356
 
                    $subPlaylistWidget->save();
357
 
                    $this->getLog()->debug('For widget ID ' . $subPlaylistWidget->widgetId . ' enableStat was Inherit, changed to Playlist enableStat value - ' . $playlistEnableStat);
358
363
                }
359
364
            }
360
365