Added code to simplify setting values

This commit is contained in:
Christian Wolf 2019-05-22 16:32:09 +02:00
parent ed47052a59
commit a9caa06e02
3 changed files with 24 additions and 0 deletions

View File

@ -45,6 +45,14 @@ abstract class AbstractCommonClubsModel
$this->values = $values;
}
protected function setValue($key, $value)
{
if(is_null($this->values))
$this->loadDataFromDatabase();
$this->values[$key] = $value;
}
public function markAsNew($new)
{
$this->new = $new;

View File

@ -20,4 +20,18 @@ class CommonClubsModelPlace extends AbstractCommonClubsModel
return $this->getValues()['club'];
}
public function getArea()
{
return $this->getValues()['area'];
}
public function setName($name)
{
$this->setValue('name', $name);
}
public function setArea($area)
{
$this->setValue('area', $area);
}
}

View File

@ -24,6 +24,8 @@ class ClubsViewTest extends HtmlView
$id = $p->getId();
$places = $c->getPlaces();
// $places[0]->setName("abc");
// $places[0]->save();
parent::display($tpl);
}