fix: Определения типов
This commit is contained in:
parent
987d4097c9
commit
acbf2c847d
10 changed files with 42 additions and 19 deletions
|
|
@ -14,7 +14,7 @@ use Exception,
|
||||||
/**
|
/**
|
||||||
* Контроллер страниц
|
* Контроллер страниц
|
||||||
*/
|
*/
|
||||||
class Action
|
class Action implements ActionInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
const TEMPLATE_EXTENSION = ".html"; // Расширение для шаблонов
|
const TEMPLATE_EXTENSION = ".html"; // Расширение для шаблонов
|
||||||
|
|
@ -35,7 +35,7 @@ class Action
|
||||||
public Database $db;
|
public Database $db;
|
||||||
|
|
||||||
// Фильтры
|
// Фильтры
|
||||||
/** @var ?ActionAccess */
|
/** @var ?\ctiso\Filter\ActionAccess */
|
||||||
public $access = null; // Обьект хранит параметры доступа
|
public $access = null; // Обьект хранит параметры доступа
|
||||||
public $logger = null; // Обьект для ведения лога
|
public $logger = null; // Обьект для ведения лога
|
||||||
|
|
||||||
|
|
@ -220,7 +220,6 @@ class Action
|
||||||
$access = $this->access;
|
$access = $this->access;
|
||||||
$url = new Url();
|
$url = new Url();
|
||||||
|
|
||||||
//print_r([$name, $param]);
|
|
||||||
if ($access == null || $access->checkAction($actionName)) {
|
if ($access == null || $access->checkAction($actionName)) {
|
||||||
$moduleName = explode("\\", strtolower(get_class($this)));
|
$moduleName = explode("\\", strtolower(get_class($this)));
|
||||||
if (count($moduleName) > 2) {
|
if (count($moduleName) > 2) {
|
||||||
|
|
|
||||||
11
src/Controller/ActionInterface.php
Normal file
11
src/Controller/ActionInterface.php
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ctiso\Controller;
|
||||||
|
use ctiso\HttpRequest;
|
||||||
|
|
||||||
|
interface ActionInterface {
|
||||||
|
function execute(HttpRequest $request);
|
||||||
|
function getConnection();
|
||||||
|
function getView($name, $class);
|
||||||
|
function addUrlPart($key, $value);
|
||||||
|
}
|
||||||
|
|
@ -63,6 +63,7 @@ class Front extends Action
|
||||||
$ucpart = ucfirst($second);
|
$ucpart = ucfirst($second);
|
||||||
|
|
||||||
$moduleClass = "Modules\\$ucname\\$ucpart";
|
$moduleClass = "Modules\\$ucname\\$ucpart";
|
||||||
|
/** @var Action $module */
|
||||||
$module = new $moduleClass();
|
$module = new $moduleClass();
|
||||||
|
|
||||||
// Инициализация модуля
|
// Инициализация модуля
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class Table
|
||||||
/**
|
/**
|
||||||
* Устанавливает высоту ряда
|
* Устанавливает высоту ряда
|
||||||
* @param int $row Номер ряда
|
* @param int $row Номер ряда
|
||||||
* @param number $value Высота ряда
|
* @param numeric $value Высота ряда
|
||||||
*/
|
*/
|
||||||
function setRowHeight (int $row, $value)
|
function setRowHeight (int $row, $value)
|
||||||
{
|
{
|
||||||
|
|
@ -147,7 +147,7 @@ class Table
|
||||||
*/
|
*/
|
||||||
function addRow(int $index = 1, array $data = [""])
|
function addRow(int $index = 1, array $data = [""])
|
||||||
{
|
{
|
||||||
assert(is_numeric($index) && $index > 0);
|
assert($index > 0);
|
||||||
$offset = $this->getRows() + 1;
|
$offset = $this->getRows() + 1;
|
||||||
|
|
||||||
$this->setRow($offset, $index, $data);
|
$this->setRow($offset, $index, $data);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class ActionAccess
|
||||||
public $user;
|
public $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Filter $processor
|
* @param FilterInterface $processor
|
||||||
*/
|
*/
|
||||||
function __construct($processor, $user) {
|
function __construct($processor, $user) {
|
||||||
$this->processor = $processor;
|
$this->processor = $processor;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use ctiso\Role\UserInterface,
|
||||||
ctiso\HttpRequest;
|
ctiso\HttpRequest;
|
||||||
|
|
||||||
/* Переделать формат Логов на список json */
|
/* Переделать формат Логов на список json */
|
||||||
class ActionLogger
|
class ActionLogger implements FilterInterface
|
||||||
{
|
{
|
||||||
public $before = array();
|
public $before = array();
|
||||||
public $file;
|
public $file;
|
||||||
|
|
@ -14,9 +14,9 @@ class ActionLogger
|
||||||
public $processor;
|
public $processor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $processor Filter
|
* @param \ctiso\Controller\ActionInterface $processor
|
||||||
* @param $logPath string
|
* @param string $logPath
|
||||||
* @param $user UserInterface
|
* @param UserInterface $user
|
||||||
*/
|
*/
|
||||||
function __construct($processor, $logPath, $user) {
|
function __construct($processor, $logPath, $user) {
|
||||||
$this->processor = $processor;
|
$this->processor = $processor;
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ namespace ctiso\Filter;
|
||||||
use ctiso\Controller\Action,
|
use ctiso\Controller\Action,
|
||||||
ctiso\HttpRequest;
|
ctiso\HttpRequest;
|
||||||
|
|
||||||
class Filter
|
class Filter implements \ctiso\Controller\ActionInterface
|
||||||
{
|
{
|
||||||
/** @var Action */
|
/** @var \ctiso\Controller\ActionInterface */
|
||||||
public $processor;
|
public $processor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Action $processor
|
* @param \ctiso\Controller\ActionInterface $processor
|
||||||
*/
|
*/
|
||||||
public function __construct($processor)
|
public function __construct($processor)
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +26,7 @@ class Filter
|
||||||
return $this->processor->execute($request);
|
return $this->processor->execute($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getView($name, $class = 'ctiso\\View\\Top')
|
public function getView($name, $class = \ctiso\View\Top::class)
|
||||||
{
|
{
|
||||||
return $this->processor->getView($name, $class);
|
return $this->processor->getView($name, $class);
|
||||||
}
|
}
|
||||||
|
|
@ -35,4 +35,8 @@ class Filter
|
||||||
{
|
{
|
||||||
return $this->processor->getConnection();
|
return $this->processor->getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addUrlPart($key, $value) {
|
||||||
|
$this->processor->addUrlPart($key, $value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
src/Filter/FilterInterface.php
Normal file
8
src/Filter/FilterInterface.php
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ctiso\Filter;
|
||||||
|
use ctiso\HttpRequest;
|
||||||
|
|
||||||
|
interface FilterInterface {
|
||||||
|
function execute(HttpRequest $request);
|
||||||
|
}
|
||||||
|
|
@ -223,7 +223,7 @@ class Functions {
|
||||||
* @example key_values('a', array(1 => array('a' => 1, 'b' => 2))) => array(1)
|
* @example key_values('a', array(1 => array('a' => 1, 'b' => 2))) => array(1)
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param array|ArrayIterator $array
|
* @param array|\ArrayIterator $array
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
static function key_values($key, $array) {
|
static function key_values($key, $array) {
|
||||||
|
|
@ -237,7 +237,7 @@ class Functions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param array|ArrayIterator $array
|
* @param array|\ArrayIterator $array
|
||||||
*/
|
*/
|
||||||
static function key_values_object($key, $array) {
|
static function key_values_object($key, $array) {
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue