1:n relations have been successfully read.

This commit is contained in:
2019-05-22 16:07:01 +02:00
parent cb624c19eb
commit 7c18f48b2a
6 changed files with 65 additions and 1 deletions

View File

@@ -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.

View File

@@ -56,5 +56,8 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
return $this->getValues()['president'];
}
public function getPlaces()
{
return $this->fetchAssociatedElements(new CommonClubsModelFactoryPlace(), 'clubid');
}
}

View 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';
}
}

View 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'];
}
}