~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Factory/WidgetMediaFactory.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:
23
23
namespace Xibo\Factory;
24
24
 
25
25
 
26
 
use Xibo\Service\LogServiceInterface;
27
 
use Xibo\Service\SanitizerServiceInterface;
28
 
use Xibo\Storage\StorageServiceInterface;
29
 
 
30
26
class WidgetMediaFactory extends BaseFactory
31
27
{
32
28
    /**
33
 
     * Construct a factory
34
 
     * @param StorageServiceInterface $store
35
 
     * @param LogServiceInterface $log
36
 
     * @param SanitizerServiceInterface $sanitizerService
37
 
     */
38
 
    public function __construct($store, $log, $sanitizerService)
39
 
    {
40
 
        $this->setCommonDependencies($store, $log, $sanitizerService);
41
 
    }
42
 
 
43
 
    /**
44
29
     * Media Linked to Widgets by WidgetId
45
30
     * @param int $widgetId
46
31
     * @return array[int]
47
32
     */
48
 
    public function getByWidgetId($widgetId)
 
33
    public static function getByWidgetId($widgetId)
49
34
    {
50
 
        return $this->query(null, array('widgetId' => $widgetId));
 
35
        return WidgetMediaFactory::query(null, array('widgetId' => $widgetId));
51
36
    }
52
37
 
53
38
    /**
56
41
     * @param array $filterBy
57
42
     * @return array[int]
58
43
     */
59
 
    public function query($sortOrder = null, $filterBy = [])
 
44
    public static function query($sortOrder = null, $filterBy = null)
60
45
    {
61
 
        $sql = 'SELECT mediaId FROM `lkwidgetmedia` WHERE widgetId = :widgetId AND mediaId <> 0 ';
 
46
        $sql = 'SELECT mediaId FROM `lkwidgetmedia` WHERE widgetId = :widgetId';
62
47
 
63
 
        return array_map(function($element) { return $element['mediaId']; }, $this->getStore()->select($sql, array('widgetId' => $this->getSanitizer()->getInt('widgetId', $filterBy))));
 
48
        return array_map(function($element) { return $element['mediaId']; }, \Xibo\Storage\PDOConnect::select($sql, array('widgetId' => \Xibo\Helper\Sanitize::getInt('widgetId', $filterBy))));
64
49
    }
65
50
}
 
 
b'\\ No newline at end of file'