New behaviour for register components in models
This commit is contained in:
parent
fe66a759d5
commit
415ae99b14
2 changed files with 28 additions and 13 deletions
16
bin/padmin
16
bin/padmin
|
|
@ -14,8 +14,11 @@ else
|
||||||
|
|
||||||
use PhangoApp\PhaModels\SQLClass;
|
use PhangoApp\PhaModels\SQLClass;
|
||||||
use PhangoApp\PhaModels\Webmodel;
|
use PhangoApp\PhaModels\Webmodel;
|
||||||
|
use PhangoApp\PhaUtils\Utils;
|
||||||
use League\CLImate\CLImate;
|
use League\CLImate\CLImate;
|
||||||
|
|
||||||
|
Utils::load_config('config');
|
||||||
|
|
||||||
$options=getopt('', array('model:'));
|
$options=getopt('', array('model:'));
|
||||||
|
|
||||||
padminConsole($options);
|
padminConsole($options);
|
||||||
|
|
@ -32,9 +35,9 @@ function padminConsole($options)
|
||||||
|
|
||||||
//echo "Use: php console.php -m=padmin -c=padmin --model=module/model\n";
|
//echo "Use: php console.php -m=padmin -c=padmin --model=module/model\n";
|
||||||
|
|
||||||
$climate->white()->backgroundBlack()->out("Use: padmin --model=module/model");
|
$climate->white()->backgroundBlack()->out("Use: padmin --model=path/to/model");
|
||||||
|
|
||||||
die;
|
exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,16 +46,16 @@ function padminConsole($options)
|
||||||
settype($arr_option[0], 'string');
|
settype($arr_option[0], 'string');
|
||||||
settype($arr_option[1], 'string');
|
settype($arr_option[1], 'string');
|
||||||
|
|
||||||
Webmodel::$model_path='./modules/';
|
#Webmodel::$model_path='./modules/';
|
||||||
|
|
||||||
$model_file=Webmodel::$model_path.$arr_option[0].'/models/models_'.$arr_option[1].'.php';
|
$model_file=$options['model'].'.php';
|
||||||
|
|
||||||
if(!is_file($model_file))
|
if(!is_file($model_file))
|
||||||
{
|
{
|
||||||
|
|
||||||
$climate->white()->backgroundRed()->out("Error: cannot find the model file in ".$arr_option[0]."/models/models_".$arr_option[1].".php");
|
$climate->white()->backgroundRed()->out("Error: cannot find the model file in ".$arr_option[0]."/models/models_".$arr_option[1].".php");
|
||||||
|
|
||||||
die();
|
exit(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,8 +71,7 @@ function padminConsole($options)
|
||||||
} catch(Exception $e)
|
} catch(Exception $e)
|
||||||
{
|
{
|
||||||
$climate->white()->backgroundRed()->out($e->getMessage());
|
$climate->white()->backgroundRed()->out($e->getMessage());
|
||||||
//echo $e->getMessage()."\n";
|
exit(1);
|
||||||
die;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace PhangoApp\PhaModels;
|
namespace PhangoApp\PhaModels;
|
||||||
|
|
||||||
use PhangoApp\PhaI18n\I18n;
|
use PhangoApp\PhaI18n\I18n;
|
||||||
|
use PhangoApp\PhaModels\CoreFields\PrimaryField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most important class for the framework
|
* The most important class for the framework
|
||||||
|
|
@ -265,7 +266,7 @@ class Webmodel {
|
||||||
|
|
||||||
$this->name=$name_model;
|
$this->name=$name_model;
|
||||||
$this->idmodel='Id'.ucfirst($this->name);
|
$this->idmodel='Id'.ucfirst($this->name);
|
||||||
$this->components[$this->idmodel]=new \PrimaryField();
|
$this->components[$this->idmodel]=new PrimaryField();
|
||||||
$this->label=$this->name;
|
$this->label=$this->name;
|
||||||
|
|
||||||
if(!isset(Webmodel::$connection_func[$this->db_selected]))
|
if(!isset(Webmodel::$connection_func[$this->db_selected]))
|
||||||
|
|
@ -277,8 +278,6 @@ class Webmodel {
|
||||||
|
|
||||||
$this->cache=$cache;
|
$this->cache=$cache;
|
||||||
$this->type_cache=$type_cache;
|
$this->type_cache=$type_cache;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1097,6 +1096,17 @@ class Webmodel {
|
||||||
|
|
||||||
return SQLClass::webtsys_query($sql_query);
|
return SQLClass::webtsys_query($sql_query);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method used for update tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function update_table()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1582,11 +1592,14 @@ class Webmodel {
|
||||||
* @param string $arguments Array with arguments for construct the new field
|
* @param string $arguments Array with arguments for construct the new field
|
||||||
* @param boolean $required A boolean used for set the default required value
|
* @param boolean $required A boolean used for set the default required value
|
||||||
*/
|
*/
|
||||||
public function register($name, $type, $arguments, $required=0)
|
public function register($name, $type_class, $required=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
$rc=new \ReflectionClass($type);
|
/*$rc=new \ReflectionClass($type);
|
||||||
$this->components[$name]=$rc->newInstanceArgs($arguments);
|
$this->components[$name]=$rc->newInstanceArgs($arguments);*/
|
||||||
|
|
||||||
|
$this->components[$name]=&$type_class;
|
||||||
|
|
||||||
//Set first label...
|
//Set first label...
|
||||||
$this->components[$name]->label=Webmodel::set_name_default($name);
|
$this->components[$name]->label=Webmodel::set_name_default($name);
|
||||||
$this->components[$name]->name_model=$this->name;
|
$this->components[$name]->name_model=$this->name;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue