3
* Spring Signage Ltd - http://www.springsignage.com
4
* Copyright (C) 2016 Spring Signage Ltd
7
* Xibo is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU Affero General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
12
* Xibo is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU Affero General Public License for more details.
17
* You should have received a copy of the GNU Affero General Public License
18
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
24
define('PROJECT_ROOT', realpath(__DIR__ . '/..'));
27
ini_set('display_errors', 0);
29
require PROJECT_ROOT . '/vendor/autoload.php';
31
if (!file_exists(PROJECT_ROOT . '/web/settings.php'))
32
die('Not configured');
34
// convert all the command line arguments into a URL
35
$argv = $GLOBALS['argv'];
36
array_shift($GLOBALS['argv']);
37
$pathInfo = '/' . implode('/', $argv);
40
$logger = new \Xibo\Helper\AccessibleMonologWriter(array(
43
new \Xibo\Helper\DatabaseLogHandler()
45
'processors' => array(
46
new \Xibo\Helper\LogProcessor(),
47
new \Monolog\Processor\UidProcessor(7)
51
$app = new \RKA\Slim(array(
53
'log.writer' => $logger
55
$app->setName('console');
58
$app->configService = \Xibo\Service\ConfigService::Load(PROJECT_ROOT . '/web/settings.php');
60
// Set up the environment so that Slim can route
61
$app->environment = Slim\Environment::mock([
62
'PATH_INFO' => $pathInfo
66
$twig = new \Slim\Views\Twig();
67
$twig->parserOptions = array(
69
'cache' => PROJECT_ROOT . '/cache'
71
$twig->parserExtensions = array(
72
new \Slim\Views\TwigExtension(),
73
new \Xibo\Twig\TransExtension(),
74
new \Xibo\Twig\ByteFormatterTwigExtension(),
75
new \Xibo\Twig\UrlDecodeTwigExtension(),
76
new \Xibo\Twig\DateFormatTwigExtension()
79
// Configure the template folder
80
$twig->twigTemplateDirs = [PROJECT_ROOT . '/views'];
84
\Xibo\Middleware\Storage::setStorage($app->container);
85
\Xibo\Middleware\State::setState($app);
86
$app->configService->loadTheme();
88
$app->add(new \Xibo\Middleware\Storage());
89
$app->add(new \Xibo\Middleware\Xmr());
91
// Handle additional Middleware
92
\Xibo\Middleware\State::setMiddleWare($app);
95
$app->user = $app->userFactory->getSystemUser();
97
// Configure the Slim error handler
98
$app->error(function (\Exception $e) use ($app) {
99
$app->container->get('\Xibo\Controller\Error')->handler($e);
102
// Configure a not found handler
103
$app->notFound(function () use ($app) {
104
$app->container->get('\Xibo\Controller\Error')->notFound();
108
$app->get('/', '\Xibo\Controller\Task:poll');
109
$app->get('/:id', '\Xibo\Controller\Task:run');