diff options
Diffstat (limited to 'lib/Minz/ActionController.php')
| -rw-r--r-- | lib/Minz/ActionController.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/Minz/ActionController.php b/lib/Minz/ActionController.php index c9551a016..553862bab 100644 --- a/lib/Minz/ActionController.php +++ b/lib/Minz/ActionController.php @@ -21,16 +21,27 @@ class Minz_ActionController { protected $view; /** - * Gives the possibility to override the default View type. + * Gives the possibility to override the default view model type. * @var class-string + * @deprecated Use constructor with view type instead */ - public static $viewType = 'Minz_View'; + public static $defaultViewType = Minz_View::class; - public function __construct () { + /** + * @phpstan-param class-string|'' $viewType + * @param string $viewType Name of the class (inheriting from Minz_View) to use for the view model + */ + public function __construct(string $viewType = '') { $this->csp_policies = self::$csp_default; $view = null; - if (class_exists(self::$viewType)) { - $view = new self::$viewType(); + if ($viewType !== '' && class_exists($viewType)) { + $view = new $viewType(); + if (!($view instanceof Minz_View)) { + $view = null; + } + } + if ($view === null && class_exists(self::$defaultViewType)) { + $view = new self::$defaultViewType(); if (!($view instanceof Minz_View)) { $view = null; } |
