diff --git a/src/admin/common/abstract/model/factory.php b/src/admin/common/abstract/model/factory.php index d27f5c8..491799c 100644 --- a/src/admin/common/abstract/model/factory.php +++ b/src/admin/common/abstract/model/factory.php @@ -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. diff --git a/src/admin/common/models/club.php b/src/admin/common/models/club.php index 024ebdb..d523b29 100644 --- a/src/admin/common/models/club.php +++ b/src/admin/common/models/club.php @@ -56,5 +56,8 @@ class CommonClubsModelClub extends AbstractCommonClubsModel return $this->getValues()['president']; } - + public function getPlaces() + { + return $this->fetchAssociatedElements(new CommonClubsModelFactoryPlace(), 'clubid'); + } } diff --git a/src/admin/common/models/factory/place.php b/src/admin/common/models/factory/place.php new file mode 100644 index 0000000..a08046e --- /dev/null +++ b/src/admin/common/models/factory/place.php @@ -0,0 +1,27 @@ +array(), + 'club'=>array('col'=>'clubid', 'type'=>'ref', 'ref'=>'CommonClubsModelClub') + ); + } + + public function getTableName() + { + return '#__club_places'; + } + + public function getClassName() + { + return 'CommonClubsModelPlace'; + } + + +} \ No newline at end of file diff --git a/src/admin/common/models/place.php b/src/admin/common/models/place.php new file mode 100644 index 0000000..c8619f3 --- /dev/null +++ b/src/admin/common/models/place.php @@ -0,0 +1,23 @@ +getValues()['name']; + } + + public function getClub() + { + return $this->getValues()['club']; + } + +} \ No newline at end of file diff --git a/src/admin/views/test/tmpl/default.php b/src/admin/views/test/tmpl/default.php index 008dd17..18076f7 100644 --- a/src/admin/views/test/tmpl/default.php +++ b/src/admin/views/test/tmpl/default.php @@ -14,3 +14,6 @@ ClubName: club->getIban(); ?>
ClubName: club->getBic(); ?>
ClubName: club->isCharitable(); ?>
ClubName: club->getPresident()->getName(); ?>
+club->getPlaces() as $place): ?> +Place: getName(); ?>
+ diff --git a/src/admin/views/test/view.html.php b/src/admin/views/test/view.html.php index dd1fc89..94eafec 100644 --- a/src/admin/views/test/view.html.php +++ b/src/admin/views/test/view.html.php @@ -19,6 +19,12 @@ class ClubsViewTest extends HtmlView $this->club = $this->clubs[0]; + $c = $this->club; + $p = $c->getPresident(); + $id = $p->getId(); + + $places = $c->getPlaces(); + parent::display($tpl); }