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"; // Расширение для шаблонов
|
||||
|
|
@ -35,7 +35,7 @@ class Action
|
|||
public Database $db;
|
||||
|
||||
// Фильтры
|
||||
/** @var ?ActionAccess */
|
||||
/** @var ?\ctiso\Filter\ActionAccess */
|
||||
public $access = null; // Обьект хранит параметры доступа
|
||||
public $logger = null; // Обьект для ведения лога
|
||||
|
||||
|
|
@ -220,7 +220,6 @@ class Action
|
|||
$access = $this->access;
|
||||
$url = new Url();
|
||||
|
||||
//print_r([$name, $param]);
|
||||
if ($access == null || $access->checkAction($actionName)) {
|
||||
$moduleName = explode("\\", strtolower(get_class($this)));
|
||||
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);
|
||||
|
||||
$moduleClass = "Modules\\$ucname\\$ucpart";
|
||||
/** @var Action $module */
|
||||
$module = new $moduleClass();
|
||||
|
||||
// Инициализация модуля
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Table
|
|||
/**
|
||||
* Устанавливает высоту ряда
|
||||
* @param int $row Номер ряда
|
||||
* @param number $value Высота ряда
|
||||
* @param numeric $value Высота ряда
|
||||
*/
|
||||
function setRowHeight (int $row, $value)
|
||||
{
|
||||
|
|
@ -147,7 +147,7 @@ class Table
|
|||
*/
|
||||
function addRow(int $index = 1, array $data = [""])
|
||||
{
|
||||
assert(is_numeric($index) && $index > 0);
|
||||
assert($index > 0);
|
||||
$offset = $this->getRows() + 1;
|
||||
|
||||
$this->setRow($offset, $index, $data);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class ActionAccess
|
|||
public $user;
|
||||
|
||||
/**
|
||||
* @param Filter $processor
|
||||
* @param FilterInterface $processor
|
||||
*/
|
||||
function __construct($processor, $user) {
|
||||
$this->processor = $processor;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use ctiso\Role\UserInterface,
|
|||
ctiso\HttpRequest;
|
||||
|
||||
/* Переделать формат Логов на список json */
|
||||
class ActionLogger
|
||||
class ActionLogger implements FilterInterface
|
||||
{
|
||||
public $before = array();
|
||||
public $file;
|
||||
|
|
@ -14,9 +14,9 @@ class ActionLogger
|
|||
public $processor;
|
||||
|
||||
/**
|
||||
* @param $processor Filter
|
||||
* @param $logPath string
|
||||
* @param $user UserInterface
|
||||
* @param \ctiso\Controller\ActionInterface $processor
|
||||
* @param string $logPath
|
||||
* @param UserInterface $user
|
||||
*/
|
||||
function __construct($processor, $logPath, $user) {
|
||||
$this->processor = $processor;
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ namespace ctiso\Filter;
|
|||
use ctiso\Controller\Action,
|
||||
ctiso\HttpRequest;
|
||||
|
||||
class Filter
|
||||
class Filter implements \ctiso\Controller\ActionInterface
|
||||
{
|
||||
/** @var Action */
|
||||
/** @var \ctiso\Controller\ActionInterface */
|
||||
public $processor;
|
||||
|
||||
/**
|
||||
* @param Action $processor
|
||||
* @param \ctiso\Controller\ActionInterface $processor
|
||||
*/
|
||||
public function __construct($processor)
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ class Filter
|
|||
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);
|
||||
}
|
||||
|
|
@ -35,4 +35,8 @@ class Filter
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ class Login extends Filter
|
|||
$request->set('lastupdate', true);
|
||||
return false;
|
||||
}*/
|
||||
// Проверка на количества попыток авторизации
|
||||
// Проверка на количества попыток авторизации
|
||||
$lastAttempt = $result;
|
||||
|
||||
if ($lastAttempt->get('trie_count') >= self::AUTH_MAX_ATTEMPT /*&& time() - $lastAttempt['trie_time'] < self::AUTH_LAST_ATTEMPT_TIMER*/) {
|
||||
|
|
@ -100,7 +100,7 @@ class Login extends Filter
|
|||
$result = $this->role->getUserByLogin($login); // Поиск по логину
|
||||
if ($result) {
|
||||
$temp = md5($result->getString('password') . $result->getString('login') . $result->getString('sid'));
|
||||
if ($password == $temp) {
|
||||
if ($password == $temp) {
|
||||
$this->enter($result);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ class Login extends Filter
|
|||
return false;
|
||||
}
|
||||
|
||||
private function enter($result)
|
||||
private function enter($result)
|
||||
{
|
||||
$this->user = $result;
|
||||
$random = rand(0, 1024 * 1024);
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ class Functions {
|
|||
* @example key_values('a', array(1 => array('a' => 1, 'b' => 2))) => array(1)
|
||||
*
|
||||
* @param string $key
|
||||
* @param array|ArrayIterator $array
|
||||
* @param array|\ArrayIterator $array
|
||||
* @return mixed
|
||||
*/
|
||||
static function key_values($key, $array) {
|
||||
|
|
@ -237,7 +237,7 @@ class Functions {
|
|||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param array|ArrayIterator $array
|
||||
* @param array|\ArrayIterator $array
|
||||
*/
|
||||
static function key_values_object($key, $array) {
|
||||
$result = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue