Completed
Push — master ( d006f2...210521 )
by Maurício
01:50 queued 29s
created

classes/Controllers/Table/TriggersController.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\Controllers\Table;
6
7
use PhpMyAdmin\Controllers\AbstractController;
8
use PhpMyAdmin\Database\Triggers;
9
use PhpMyAdmin\DatabaseInterface;
10
use PhpMyAdmin\DbTableExists;
11
use PhpMyAdmin\Http\ServerRequest;
12
use PhpMyAdmin\ResponseRenderer;
0 ignored issues
show
The type PhpMyAdmin\ResponseRenderer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use PhpMyAdmin\Template;
14
use PhpMyAdmin\Url;
15
use PhpMyAdmin\Util;
16
17
use function in_array;
18
use function strlen;
19
20
/**
21
 * Triggers management.
22
 */
23
class TriggersController extends AbstractController
24
{
25 4
    public function __construct(
26
        ResponseRenderer $response,
27
        Template $template,
28
        private DatabaseInterface $dbi,
29
        private Triggers $triggers,
30
    ) {
31 4
        parent::__construct($response, $template);
32
    }
33
34 4
    public function __invoke(ServerRequest $request): void
35
    {
36 4
        $GLOBALS['errors'] ??= null;
37 4
        $GLOBALS['urlParams'] ??= null;
38 4
        $GLOBALS['errorUrl'] ??= null;
39
40 4
        $this->addScriptFiles(['database/triggers.js']);
41
42 4
        if (! $this->response->isAjax()) {
43
            /**
44
             * Displays the header and tabs
45
             */
46 4
            if (! empty($GLOBALS['table']) && in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']))) {
47 4
                $this->checkParameters(['db', 'table']);
48
49 4
                $GLOBALS['urlParams'] = ['db' => $GLOBALS['db'], 'table' => $GLOBALS['table']];
50 4
                $GLOBALS['errorUrl'] = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
51 4
                $GLOBALS['errorUrl'] .= Url::getCommon($GLOBALS['urlParams'], '&');
52
53 4
                DbTableExists::check($GLOBALS['db'], $GLOBALS['table']);
54
            } else {
55
                $GLOBALS['table'] = '';
56
57
                $this->checkParameters(['db']);
58
59
                $GLOBALS['errorUrl'] = Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
60
                $GLOBALS['errorUrl'] .= Url::getCommon(['db' => $GLOBALS['db']], '&');
61
62
                if (! $this->hasDatabase()) {
63 4
                    return;
64
                }
65
            }
66
        } elseif (strlen($GLOBALS['db']) > 0) {
67
            $this->dbi->selectDb($GLOBALS['db']);
68
        }
69
70
        /**
71
         * Keep a list of errors that occurred while
72
         * processing an 'Add' or 'Edit' operation.
73
         */
74 4
        $GLOBALS['errors'] = [];
75
76 4
        $this->triggers->main();
77
    }
78
}
79