From eba0f794f7f6677d62e956edfa849be06d671d3b Mon Sep 17 00:00:00 2001 From: Mofasa Date: Fri, 14 Sep 2018 12:36:09 +0800 Subject: [PATCH 1/2] View, add view dirs it'd be helpful to add extra view dir(s) in `module.php`. ```php $di->view->setViewsDir(array_merge((array)$di->view->getViewsDir(), ['...'])); vs $di->view->addViewsDir(['...']); ``` --- ice/mvc/view.zep | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ice/mvc/view.zep b/ice/mvc/view.zep index 6741bc6e..5b318cee 100644 --- a/ice/mvc/view.zep +++ b/ice/mvc/view.zep @@ -199,6 +199,19 @@ class View extends Arr implements ViewInterface return this; } + /** + * Add view directory. + * + * @param mixed dir View directory or directories + * @return object View + */ + public function addViewsDir(var dir) + { + let this->viewsDir = array_unique(array_merge((array)this->viewsDir, (array)dir)); + + return this; + } + /** * Magic toStrint, get the rendered view. */ From 1713f5069300b6d4fabed06306e2f5ea38de8427 Mon Sep 17 00:00:00 2001 From: Mofasa Date: Sat, 15 Sep 2018 14:37:17 +0800 Subject: [PATCH 2/2] Allow to prepend to the current views dir --- ice/mvc/view.zep | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ice/mvc/view.zep b/ice/mvc/view.zep index 5b318cee..3f0f37c9 100644 --- a/ice/mvc/view.zep +++ b/ice/mvc/view.zep @@ -203,11 +203,20 @@ class View extends Arr implements ViewInterface * Add view directory. * * @param mixed dir View directory or directories + * @param boolean prepend Prepend to the current views dir * @return object View */ - public function addViewsDir(var dir) + public function addViewsDir(var dir, boolean prepend = false) { - let this->viewsDir = array_unique(array_merge((array)this->viewsDir, (array)dir)); + var dirs; + + if prepend { + let dirs = array_merge((array)dir, (array)this->viewsDir); + } else { + let dirs = array_merge((array)this->viewsDir, (array)dir); + } + + let this->viewsDir = array_unique(dirs); return this; }