From ed1e4ee167588f4ad1079faa1a5b028f7d7499ff Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 10 Mar 2018 19:10:45 +0000 Subject: [PATCH] cli : Add controllersDir and modelsDir methods to set multiple pathes for controllers and models git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4158 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- cli.php | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/cli.php b/cli.php index ec2c2de..81740b5 100644 --- a/cli.php +++ b/cli.php @@ -20,6 +20,14 @@ class cli /** Quiet mode don't display empty results */ private $QUIET; + /** Store the controllers pathes to test + */ + private $controllersPath = array ("controllers/*.php"); + + /** Store the models pathes to test + */ + private $modelsPath = array ("models/*.php"); + /** The construtor define the catching of the errors */ public function __construct () { @@ -30,6 +38,26 @@ class cli set_error_handler(array(&$this, "cliErrorHandler")); } + /** Define the controllers path + * @param string|array The controllers pathes to use + */ + public function controllersDir ($path) + { + if (! is_array ($path)) + $path = array ($path); + $this->controllersPath = $path; + } + + /** Define the models path + * @param string|array The models pathes to use + */ + public function modelsDir ($path) + { + if (! is_array ($path)) + $path = array ($path); + $this->modelsPath = $path; + } + /** The error handler for CLI : display error in STDERR * @param integer $errno The error type * @param string $errstr The string to send in error @@ -120,9 +148,18 @@ class cli } // List the controllers and the models if the expert mode is activated - $files = glob ("controllers/*.php"); + $files = array (); + foreach ($this->controllersPath as $path) + { + $files = array_merge ($files, glob ($path)); + } if ($this->EXPERT) - $files = array_merge ($files, glob ("models/*.php")); + { + foreach ($this->modelsPath as $path) + { + $files = array_merge ($files, glob ($path)); + } + } if (count ($files) === 0 && $this->EXPERT === FALSE) { if (isset ($argv[0]) && $argv[0] === "-listonly")