Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
CliController
n/a
0 / 0
n/a
0 / 0
3
n/a
0 / 0
 viewEmptyCommand
n/a
0 / 0
n/a
0 / 0
2
 cliRunEvent
n/a
0 / 0
n/a
0 / 0
1
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   Modules\Admin
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace Modules\Admin\Controller;
16
17use phpOMS\Contract\RenderableInterface;
18use phpOMS\Message\RequestAbstract;
19use phpOMS\Message\ResponseAbstract;
20use phpOMS\Views\View;
21
22/**
23 * Admin controller class.
24 *
25 * This class is responsible for the basic admin activities such as managing accounts, groups, permissions and modules.
26 *
27 * @package Modules\Admin
28 * @license OMS License 2.0
29 * @link    https://jingga.app
30 * @since   1.0.0
31 */
32final class CliController extends Controller
33{
34    /**
35     * Method which generates the general settings view.
36     *
37     * In this view general settings for the entire application can be seen and adjusted. Settings which can be modified
38     * here are localization, password, database, etc.
39     *
40     * @param RequestAbstract  $request  Request
41     * @param ResponseAbstract $response Response
42     * @param array            $data     Generic data
43     *
44     * @return RenderableInterface Response can be rendered
45     *
46     * @since 1.0.0
47     * @codeCoverageIgnore
48     */
49    public function viewEmptyCommand(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
50    {
51        $view = new View($this->app->l11nManager, $request, $response);
52
53        if ($request->hasData('v')) {
54            $view->setTemplate('/Modules/Admin/Theme/Cli/version-command');
55        } else {
56            $view->setTemplate('/Modules/Admin/Theme/Cli/empty-command');
57        }
58
59        return $view;
60    }
61
62    /**
63     * Find and run events
64     *
65     * This is mostly used by the web applications to offload searching for event hooks and of course running the events which might take a long time for complex events.
66     *
67     * @param RequestAbstract  $request  Request
68     * @param ResponseAbstract $response Response
69     * @param array            $data     Generic data
70     *
71     * @return RenderableInterface Response can be rendered
72     *
73     * @since 1.0.0
74     * @codeCoverageIgnore
75     */
76    public function cliRunEvent(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
77    {
78        $event = $this->app->eventManager->triggerSimilar(
79            $request->getDataString('g') ?? '',
80            $request->getDataString('i') ?? '',
81            $request->getDataJson('d')
82        );
83
84        $view = new View($this->app->l11nManager, $request, $response);
85        $view->setTemplate('/Modules/Admin/Theme/Cli/event-result');
86
87        $view->data['event'] = $event;
88
89        return $view;
90    }
91}