From de26531178c61c98dcb7b7634c9e5891c302f615 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 15 Aug 2019 17:19:12 +0200 Subject: tec: Provide a Minz_Mailer class (#2476) * Add Minz_View::_path method (replace change_view) The `_path` method is more powerful since it allows to choose the file extension. It is also Minz_Request-agnostic, which is useful to reuse the Minz_View class in other places. `change_view` is now deprecated and a warning is logged if we use it. * Provide a Minz_Mailer to send emails It uses PHPMailer under the hood and only supports PHP >= 5.5 --- lib/Minz/View.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/Minz/View.php') diff --git a/lib/Minz/View.php b/lib/Minz/View.php index 6f044c98e..5b6676690 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -26,22 +26,27 @@ class Minz_View { * Constructeur * Détermine si on utilise un layout ou non */ - public function __construct () { - $this->change_view(Minz_Request::controllerName(), - Minz_Request::actionName()); - + public function __construct() { $this->_layout(self::LAYOUT_DEFAULT); $conf = Minz_Configuration::get('system'); self::$title = $conf->title; } /** - * Change le fichier de vue en fonction d'un controller / action + * [deprecated] Change the view file based on controller and action. */ public function change_view($controller_name, $action_name) { - $this->view_filename = self::VIEWS_PATH_NAME . '/' - . $controller_name . '/' - . $action_name . '.phtml'; + Minz_Log::warning('Minz_View::change_view is deprecated, it will be removed in a future version. Please use Minz_View::_path instead.'); + $this->_path($controller_name. '/' . $action_name . '.phtml'); + } + + /** + * Change the view file based on a pathname relative to VIEWS_PATH_NAME. + * + * @param string $path the new path + */ + public function _path($path) { + $this->view_filename = self::VIEWS_PATH_NAME . '/' . $path; } /** -- cgit v1.2.3