phpmyadmin/libraries/classes/Controllers/AbstractController.php
Maurício Meneghini Fauth 1dccc10493 Extract method for adding script files
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2020-07-12 16:58:33 -03:00

57 lines
1.3 KiB
PHP

<?php
/**
* Holds the PhpMyAdmin\Controllers\AbstractController
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Response;
use PhpMyAdmin\Template;
/**
* Base class for all of controller
*/
abstract class AbstractController
{
/** @var Response */
protected $response;
/** @var DatabaseInterface */
protected $dbi;
/** @var Template */
protected $template;
/**
* @param Response $response Response object
* @param DatabaseInterface $dbi DatabaseInterface object
* @param Template $template Template that should be used
*/
public function __construct($response, $dbi, Template $template)
{
$this->response = $response;
$this->dbi = $dbi;
$this->template = $template;
}
/**
* @param string $template Template path name.
* @param array $data Associative array of template variables.
*/
protected function render(string $template, array $data = []): void
{
$this->response->addHTML($this->template->render($template, $data));
}
/** @param string[] $files */
protected function addScriptFiles(array $files): void
{
$header = $this->response->getHeader();
$scripts = $header->getScripts();
$scripts->addFiles($files);
}
}