改名
This commit is contained in:
@@ -21,7 +21,6 @@ use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Snowflake;
|
||||
use Throwable;
|
||||
use validator\Validator;
|
||||
use function Input;
|
||||
|
||||
/**
|
||||
@@ -130,13 +129,32 @@ class Node extends HttpService
|
||||
if (empty($dispatchParam)) {
|
||||
$dispatchParam = [\request()];
|
||||
}
|
||||
// return call_user_func($this->handler, ...$dispatchParam);
|
||||
|
||||
return \aop($this->handler, $dispatchParam);
|
||||
if ($this->beforeAction()) {
|
||||
return \aop($this->handler, $dispatchParam);
|
||||
}
|
||||
return response()->close(400);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private bool $_hasBeforeAction = false;
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function beforeAction(): bool
|
||||
{
|
||||
if (!$this->_hasBeforeAction) return true;
|
||||
[$controller, $action] = $this->handler;
|
||||
if (!$controller->beforeAction(\request())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -299,6 +317,8 @@ class Node extends HttpService
|
||||
throw new Exception('method ' . $action . ' not exists at ' . $controller . '.');
|
||||
}
|
||||
|
||||
$this->_hasBeforeAction = $reflect->hasMethod('beforeAction');
|
||||
|
||||
$this->annotationInject($reflect->getName(), $action);
|
||||
|
||||
return [$reflect->newInstance(), $action];
|
||||
|
||||
Reference in New Issue
Block a user