~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Factory/WidgetAudioFactory.php

  • Committer: Dan Garner
  • Date: 2016-02-18 16:07:16 UTC
  • mfrom: (454.4.137)
  • Revision ID: git-v1:8867f12675bc9e0e67e7e622c80da7471b9f294a
Merge pull request #139 from dasgarner/feature/nested-display-groups

Feature/nested display groups

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Xibo - Digital Signage - http://www.xibo.org.uk
4
 
 * Copyright (C) 2015 Spring Signage Ltd
5
 
 *
6
 
 * This file (WidgetMediaFactory.php) is part of Xibo.
7
 
 *
8
 
 * Xibo is free software: you can redistribute it and/or modify
9
 
 * it under the terms of the GNU Affero General Public License as published by
10
 
 * the Free Software Foundation, either version 3 of the License, or
11
 
 * any later version.
12
 
 *
13
 
 * Xibo is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU Affero General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU Affero General Public License
19
 
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
20
 
 */
21
 
 
22
 
 
23
 
namespace Xibo\Factory;
24
 
 
25
 
 
26
 
use Xibo\Entity\WidgetAudio;
27
 
use Xibo\Service\LogServiceInterface;
28
 
use Xibo\Service\SanitizerServiceInterface;
29
 
use Xibo\Storage\StorageServiceInterface;
30
 
 
31
 
/**
32
 
 * Class WidgetAudioFactory
33
 
 * @package Xibo\Factory
34
 
 */
35
 
class WidgetAudioFactory extends BaseFactory
36
 
{
37
 
    /**
38
 
     * Construct a factory
39
 
     * @param StorageServiceInterface $store
40
 
     * @param LogServiceInterface $log
41
 
     * @param SanitizerServiceInterface $sanitizerService
42
 
     */
43
 
    public function __construct($store, $log, $sanitizerService)
44
 
    {
45
 
        $this->setCommonDependencies($store, $log, $sanitizerService);
46
 
    }
47
 
 
48
 
    /**
49
 
     * Create Empty
50
 
     * @return WidgetAudio
51
 
     */
52
 
    public function createEmpty()
53
 
    {
54
 
        return new WidgetAudio($this->getStore(), $this->getLog());
55
 
    }
56
 
 
57
 
    /**
58
 
     * Media Linked to Widgets by WidgetId
59
 
     * @param int $widgetId
60
 
     * @return array[int]
61
 
     */
62
 
    public function getByWidgetId($widgetId)
63
 
    {
64
 
        return $this->query(null, array('widgetId' => $widgetId));
65
 
    }
66
 
 
67
 
    /**
68
 
     * Query Media Linked to Widgets
69
 
     * @param array $sortOrder
70
 
     * @param array $filterBy
71
 
     * @return array[int]
72
 
     */
73
 
    public function query($sortOrder = null, $filterBy = [])
74
 
    {
75
 
        $entries = [];
76
 
        $sql = 'SELECT `mediaId`, `widgetId`, `volume`, `loop` FROM `lkwidgetaudio` WHERE widgetId = :widgetId AND mediaId <> 0 ';
77
 
 
78
 
        foreach ($this->getStore()->select($sql, ['widgetId' => $this->getSanitizer()->getInt('widgetId', $filterBy)]) as $row) {
79
 
            $entries[] = $this->createEmpty()->hydrate($row, ['intProperties' => ['duration']]);
80
 
        }
81
 
 
82
 
        return $entries;
83
 
    }
84
 
}
 
 
b'\\ No newline at end of file'