* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net) */ class RouterLoadViewAndControllerEvent extends Event { /** * The name of the view * * @var string */ public $viewName; /** * The type of view to be loaded * * @var string */ public $viewType; /** * The function that will be loaded in the view * * @var array */ public $viewMethods; /** * The parameters that will be provided to the function in the view * * @var string */ public $viewParameters; /** * The route that resulted in this controller and view * * @var string */ public $route; /** * A controller to be injected. * * @var Controller|null */ public $controller; public function init(string $viewName, string $viewType, array $viewMethods, string $viewParameters, string $route) { $this->viewName = $viewName; $this->viewType = $viewType; $this->viewMethods = $viewMethods; $this->viewParameters = $viewParameters; $this->route = $route; } /** * Add a method which should be tried upon calling the view * * @param string $method * @param int $priority */ public function addMethod(string $method, int $priority = Priority::NORMAL) { if (!isset($this->viewMethods[$priority])) $this->viewMethods[$priority] = []; if (!isset($this->viewMethods[$priority][$method])) $this->viewMethods[$priority][] = $method; } /** * Override the controller to be provided to the view. * * @param Controller $controller */ public function overrideController(Controller $controller) { $this->controller = $controller; } }