1:n relations have been successfully read.
This commit is contained in:
@@ -10,6 +10,8 @@ class ElementNotFoundException extends Exception
|
||||
|
||||
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.
|
||||
|
||||
@@ -56,5 +56,8 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
|
||||
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'];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user