改名
This commit is contained in:
@@ -9,7 +9,6 @@ use Database\Connection;
|
||||
use Database\DatabasesProviders;
|
||||
use Http\Client\Client;
|
||||
use Http\Client\Curl;
|
||||
use Http\HttpFilter;
|
||||
use Http\Route\Router;
|
||||
use Server\Server;
|
||||
use Kiri\Crontab\Producer;
|
||||
@@ -32,7 +31,6 @@ use Kiri\Jwt\Jwt;
|
||||
* @property Connection $databases
|
||||
* @property Curl $curl
|
||||
* @property Producer $crontab
|
||||
* @property HttpFilter $filter
|
||||
*/
|
||||
trait TraitApplication
|
||||
{
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Http;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Kiri\Abstracts\BaseObject;
|
||||
use validator\Validator;
|
||||
|
||||
/**
|
||||
* Class HttpFilter
|
||||
* @package Http\Http
|
||||
*/
|
||||
class HttpFilter extends BaseObject
|
||||
{
|
||||
|
||||
|
||||
private array $hash = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @param array $rules
|
||||
* @return $this
|
||||
*/
|
||||
public function register(string $className, string $method, array $rules): HttpFilter
|
||||
{
|
||||
$this->hash[$className . '::' . $method] = $rules;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @return array
|
||||
*/
|
||||
public function getRules(string $className, string $method): array
|
||||
{
|
||||
return $this->hash[$className . '::' . $method] ?? [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $rules
|
||||
* @return bool|Validator
|
||||
* @throws Exception
|
||||
*/
|
||||
public function check(array $rules): bool|Validator
|
||||
{
|
||||
if (empty($rules)) {
|
||||
return true;
|
||||
}
|
||||
$validator = Validator::getInstance();
|
||||
$validator->setParams(Input()->load());
|
||||
foreach ($rules as $val) {
|
||||
$field = array_shift($val);
|
||||
if (empty($val)) {
|
||||
continue;
|
||||
}
|
||||
$validator->make($field, $val);
|
||||
}
|
||||
return $validator;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Annotation\Route;
|
||||
|
||||
|
||||
use Annotation\Attribute;
|
||||
use Exception;
|
||||
use Http\HttpFilter;
|
||||
use ReflectionException;
|
||||
use Kiri\Exception\ComponentException;
|
||||
use Kiri\Exception\NotFindClassException;
|
||||
use Kiri\Kiri;
|
||||
|
||||
/**
|
||||
* Class Filter
|
||||
* @package Annotation\Route
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Filter extends Attribute
|
||||
{
|
||||
|
||||
/**
|
||||
* Filter constructor.
|
||||
* @param array $rules
|
||||
*/
|
||||
public function __construct(array $rules)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user