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
This commit is contained in:
2018-03-10 19:10:45 +00:00
parent 43649cc25d
commit ed1e4ee167

41
cli.php
View File

@@ -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")