HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/posscale/subdomains/xibo/lib/Middleware/Xmr.php
<?php
/*
 * Spring Signage Ltd - http://www.springsignage.com
 * Copyright (C) 2016 Spring Signage Ltd
 * (Xmr.php)
 */


namespace Xibo\Middleware;

use Slim\Middleware;
use Xibo\Exception\XiboException;
use Xibo\Service\DisplayNotifyService;
use Xibo\Service\PlayerActionService;

/**
 * Class Xmr
 * @package Xibo\Middleware
 */
class Xmr extends Middleware
{
    /**
     * Call
     */
    public function call()
    {
        $app = $this->getApplication();

        $app->hook('slim.before', function() {

            $app = $this->app;

            self::setXmr($app);
        });

        $this->next->call();

        // Handle display notifications
        if ($app->displayNotifyService != null) {
            try {
                $app->displayNotifyService->processQueue();
            } catch (XiboException $e) {
                $app->logService->error('Unable to Process Queue of Display Notifications due to %s', $e->getMessage());
            }
        }

        // Handle player actions
        if ($app->playerActionService != null) {
            try {
                $app->playerActionService->processQueue();
            } catch (\Exception $e) {
                $app->logService->error('Unable to Process Queue of Player actions due to %s', $e->getMessage());
            }
        }
    }

    /**
     * Set XMR
     * @param \Slim\Slim $app
     * @param bool $triggerPlayerActions
     */
    public static function setXmr($app, $triggerPlayerActions = true)
    {
        // Player Action Helper
        $app->container->singleton('playerActionService', function() use ($app, $triggerPlayerActions) {
            return new PlayerActionService($app->configService, $app->logService, $triggerPlayerActions);
        });

        // Register the display notify service
        $app->container->singleton('displayNotifyService', function () use ($app) {
            return new DisplayNotifyService(
                $app->configService,
                $app->logService,
                $app->store,
                $app->pool,
                $app->playerActionService,
                $app->dateService,
                $app->scheduleFactory,
                $app->dayPartFactory
            );
        });
    }
}