1
0
Fork 0
mirror of synced 2025-04-20 01:21:01 +00:00

don't shwallow exception when creating base class instance

This commit is contained in:
Pavel 2020-07-31 20:09:26 +03:00
parent 2c4c09d2f2
commit 1ec13508c6

View file

@ -63,14 +63,12 @@ abstract class AbstractSerializableModel
$result = call_user_func($this->getBaseClass() . '::add', $data);
}
} else {
$instance = $this->constructBaseClass();
$instance = new $this->getBaseClass();
if (!empty($instance)) {
if (method_exists($instance, 'Add')) {
$result = $instance->Add($data);
} elseif (method_exists($instance, 'add')) {
$result = $instance->add($data);
}
if (method_exists($instance, 'Add')) {
$result = $instance->Add($data);
} elseif (method_exists($instance, 'add')) {
$result = $instance->add($data);
}
}
@ -100,14 +98,12 @@ abstract class AbstractSerializableModel
$result = call_user_func($this->getBaseClass() . '::delete', $primary);
}
} else {
$instance = $this->constructBaseClass();
$instance = new $this->getBaseClass();
if (!empty($instance)) {
if (method_exists($instance, 'Delete')) {
$result = $instance->Delete($primary);
} elseif (method_exists($instance, 'delete')) {
$result = $instance->delete($primary);
}
if (method_exists($instance, 'Delete')) {
$result = $instance->Delete($primary);
} elseif (method_exists($instance, 'delete')) {
$result = $instance->delete($primary);
}
}
@ -134,22 +130,6 @@ abstract class AbstractSerializableModel
return $newResult;
}
/**
* Tries to construct base class
*
* @return mixed|null
*/
private function constructBaseClass()
{
$instance = null;
try {
$instance = new $this->getBaseClass();
} catch (\Throwable $exception) {}
return $instance;
}
/**
* Tries to return primary key from the model
*