1:n relations have been successfully read.
This commit is contained in:
parent
cb624c19eb
commit
7c18f48b2a
@ -11,6 +11,8 @@ class ElementNotFoundException extends Exception
|
|||||||
abstract class AbstractCommonClubsModelFactory
|
abstract class AbstractCommonClubsModelFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO Attribures as objects allowing to use polymophism in filtering/parsing/checking/sql building
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method should return an array to configure the trivially accessible values.
|
* This method should return an array to configure the trivially accessible values.
|
||||||
* The key must be a unique key describing the information and will be reused in the getValues() method.
|
* The key must be a unique key describing the information and will be reused in the getValues() method.
|
||||||
|
@ -56,5 +56,8 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
|
|||||||
return $this->getValues()['president'];
|
return $this->getValues()['president'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPlaces()
|
||||||
|
{
|
||||||
|
return $this->fetchAssociatedElements(new CommonClubsModelFactoryPlace(), 'clubid');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
27
src/admin/common/models/factory/place.php
Normal file
27
src/admin/common/models/factory/place.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// No direct access.
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
class CommonClubsModelFactoryPlace extends AbstractCommonClubsModelFactory
|
||||||
|
{
|
||||||
|
public function getAttributes()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'name'=>array(),
|
||||||
|
'club'=>array('col'=>'clubid', 'type'=>'ref', 'ref'=>'CommonClubsModelClub')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTableName()
|
||||||
|
{
|
||||||
|
return '#__club_places';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName()
|
||||||
|
{
|
||||||
|
return 'CommonClubsModelPlace';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
23
src/admin/common/models/place.php
Normal file
23
src/admin/common/models/place.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// No direct access.
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
class CommonClubsModelPlace extends AbstractCommonClubsModel
|
||||||
|
{
|
||||||
|
protected function getFactory()
|
||||||
|
{
|
||||||
|
return new CommonClubsModelFactoryPlace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->getValues()['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClub()
|
||||||
|
{
|
||||||
|
return $this->getValues()['club'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,3 +14,6 @@ ClubName: <?php echo $this->club->getIban(); ?> <br />
|
|||||||
ClubName: <?php echo $this->club->getBic(); ?> <br />
|
ClubName: <?php echo $this->club->getBic(); ?> <br />
|
||||||
ClubName: <?php echo $this->club->isCharitable(); ?> <br />
|
ClubName: <?php echo $this->club->isCharitable(); ?> <br />
|
||||||
ClubName: <?php echo $this->club->getPresident()->getName(); ?> <br />
|
ClubName: <?php echo $this->club->getPresident()->getName(); ?> <br />
|
||||||
|
<?php foreach($this->club->getPlaces() as $place): ?>
|
||||||
|
Place: <?php echo $place->getName(); ?><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
@ -19,6 +19,12 @@ class ClubsViewTest extends HtmlView
|
|||||||
|
|
||||||
$this->club = $this->clubs[0];
|
$this->club = $this->clubs[0];
|
||||||
|
|
||||||
|
$c = $this->club;
|
||||||
|
$p = $c->getPresident();
|
||||||
|
$id = $p->getId();
|
||||||
|
|
||||||
|
$places = $c->getPlaces();
|
||||||
|
|
||||||
parent::display($tpl);
|
parent::display($tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user