Successfully tested create, update and delete of trivial elements

This commit is contained in:
2019-05-23 17:52:11 +02:00
parent 23941f32d3
commit 8b25925ec4
5 changed files with 40 additions and 5 deletions

View File

@@ -6,6 +6,9 @@ use Joomla\CMS\Factory;
// No direct access.
defined('_JEXEC') or die;
class AssociatedObjectUnsavedException extends Exception
{}
abstract class AbstractCommonClubsModel
{
// TODO Adddata validator
@@ -27,9 +30,9 @@ abstract class AbstractCommonClubsModel
private $values = null;
protected function getValues()
protected function getValues($force = false)
{
if(is_null($this->values))
if(is_null($this->values) || $force)
$this->loadDataFromDatabase();
return $this->values;
@@ -128,7 +131,14 @@ abstract class AbstractCommonClubsModel
if(is_null($vals[$k]))
continue;
$vals[$k] = $vals[$k]->getId();
$id = $vals[$k]->getId();
if($id === 'new')
{
throw new AssociatedObjectUnsavedException();
}
$vals[$k] = $id;
}
return $vals;