Test if model class is instanciable

to handle abstract classes, interfaces...
This commit is contained in:
TANT Julien
2013-12-16 22:38:06 +01:00
parent facba3a5e6
commit 430c5d7db4
@@ -141,7 +141,12 @@ class ModelsCommand extends Command {
$this->properties = array();
$this->methods = array();
if(class_exists($name)){
try{
// handle abstract classes, interfaces, ...
$reflectionClass = new \ReflectionClass($name);
if (!$reflectionClass->IsInstantiable()) {
throw new \Exception($name . ' is not instanciable.');
}
$model = new $name();
$this->getPropertiesFromTable($model);
$this->getPropertiesFromMethods($model);