~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Upgrade/ScheduleConvertStep.php

  • Committer: Dan Garner
  • Date: 2015-08-11 09:29:02 UTC
  • mto: This revision was merged to the branch mainline in revision 453.
  • Revision ID: git-v1:a86fb4369b7395c13367577d23b14c0ab4528c1a
Transitions fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Spring Signage Ltd - http://www.springsignage.com
4
 
 * Copyright (C) 2015 Spring Signage Ltd
5
 
 * (ScheduleConvertStep.php)
6
 
 */
7
 
 
8
 
 
9
 
namespace Xibo\Upgrade;
10
 
 
11
 
 
12
 
use Xibo\Service\ConfigServiceInterface;
13
 
use Xibo\Service\LogServiceInterface;
14
 
use Xibo\Storage\StorageServiceInterface;
15
 
 
16
 
/**
17
 
 * Class ScheduleConvertStep
18
 
 * @package Xibo\Upgrade
19
 
 */
20
 
class ScheduleConvertStep implements  Step
21
 
{
22
 
    /** @var  StorageServiceInterface */
23
 
    private $store;
24
 
 
25
 
    /** @var  LogServiceInterface */
26
 
    private $log;
27
 
 
28
 
    /** @var  ConfigServiceInterface */
29
 
    private $config;
30
 
 
31
 
    /**
32
 
     * DataSetConvertStep constructor.
33
 
     * @param StorageServiceInterface $store
34
 
     * @param LogServiceInterface $log
35
 
     * @param ConfigServiceInterface $config
36
 
     */
37
 
    public function __construct($store, $log, $config)
38
 
    {
39
 
        $this->store = $store;
40
 
        $this->log = $log;
41
 
        $this->config = $config;
42
 
    }
43
 
 
44
 
    /**
45
 
     * @param \Slim\Helper\Set $container
46
 
     * @throws \Xibo\Exception\NotFoundException
47
 
     */
48
 
    public function doStep($container)
49
 
    {
50
 
        // Get all events and their Associated display group id's
51
 
        foreach ($this->store->select('SELECT eventId, displayGroupIds FROM `schedule`', []) as $event) {
52
 
            // Ping open the displayGroupIds
53
 
            $displayGroupIds = explode(',', $event['displayGroupIds']);
54
 
 
55
 
            // Construct some SQL to add the link
56
 
            $sql = 'INSERT INTO `lkscheduledisplaygroup` (eventId, displayGroupId) VALUES ';
57
 
 
58
 
            foreach ($displayGroupIds as $id) {
59
 
                $sql .= '(' . $event['eventId'] . ',' . $id . '),';
60
 
            }
61
 
 
62
 
            $sql = rtrim($sql, ',');
63
 
 
64
 
            $this->store->update($sql, []);
65
 
        }
66
 
    }
67
 
}
 
 
b'\\ No newline at end of file'