added constant

pull/545/head
n0nag0n 11 months ago
parent e29f3b5533
commit a60a31c4bd

@ -66,6 +66,16 @@ use flight\net\Route;
*/ */
class Engine class Engine
{ {
/**
* @var array<string> List of methods that can be extended in the Engine class.
*/
private const MAPPABLE_METHODS = [
'start', 'stop', 'route', 'halt', 'error', 'notFound',
'render', 'redirect', 'etag', 'lastModified', 'json', 'jsonp',
'post', 'put', 'patch', 'delete', 'group', 'getUrl'
];
/** @var array<string, mixed> Stored variables. */ /** @var array<string, mixed> Stored variables. */
protected array $vars = []; protected array $vars = [];
@ -137,14 +147,7 @@ class Engine
$view->extension = $self->get('flight.views.extension'); $view->extension = $self->get('flight.views.extension');
}); });
// Register framework methods foreach (self::MAPPABLE_METHODS as $name) {
$methods = [
'start', 'stop', 'route', 'halt', 'error', 'notFound',
'render', 'redirect', 'etag', 'lastModified', 'json', 'jsonp',
'post', 'put', 'patch', 'delete', 'group', 'getUrl',
];
foreach ($methods as $name) {
$this->dispatcher->set($name, [$this, "_$name"]); $this->dispatcher->set($name, [$this, "_$name"]);
} }

Loading…
Cancel
Save