Added second class to debug 1:n relation, which is working in general
This commit is contained in:
parent
b868f0fe86
commit
cb624c19eb
@ -141,10 +141,14 @@ abstract class AbstractCommonClubsModel
|
||||
|
||||
private function loadExternalReferenceAsObject($className, $value)
|
||||
{
|
||||
if(is_string($value) && preg_match('/^[0-9]+$/', $value))
|
||||
$value = (int) $value;
|
||||
|
||||
if(! is_int($value))
|
||||
throw new Exception('Reference with non-integer value');
|
||||
|
||||
$factory = $this->getFactoryOfClass($className);
|
||||
$factoryName = $this->getFactoryNameOfClass($className);
|
||||
$factory = new $factoryName();
|
||||
return $factory->loadById($value);
|
||||
}
|
||||
|
||||
@ -157,7 +161,7 @@ abstract class AbstractCommonClubsModel
|
||||
* @param string $className
|
||||
* @return AbstractCommonClubsModelFactory
|
||||
*/
|
||||
private function getFactoryOfClass($className)
|
||||
private function getFactoryNameOfClass($className)
|
||||
{
|
||||
if(empty(self::CLASSNAME_MAP[$className]))
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ class CommonClubsModelFactoryClub extends AbstractCommonClubsModelFactory
|
||||
'iban'=>array(),
|
||||
'bic'=>array(),
|
||||
'charitable'=>array('type'=>'int'),
|
||||
'president'=>array('type'=>'int', 'ref'=>'CommonClubsModelUser')
|
||||
'president'=>array('type'=>'ref', 'ref'=>'CommonClubsModelUser')
|
||||
);
|
||||
}
|
||||
|
||||
|
27
src/admin/common/models/factory/user.php
Normal file
27
src/admin/common/models/factory/user.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsModelFactoryUser extends AbstractCommonClubsModelFactory
|
||||
{
|
||||
public function getAttributes()
|
||||
{
|
||||
return array(
|
||||
'user'=>array(),
|
||||
'name'=>array()
|
||||
);
|
||||
}
|
||||
|
||||
public function getTableName()
|
||||
{
|
||||
return '#__club_users';
|
||||
}
|
||||
|
||||
public function getClassName()
|
||||
{
|
||||
return 'CommonClubsModelUser';
|
||||
}
|
||||
|
||||
|
||||
}
|
19
src/admin/common/models/user.php
Normal file
19
src/admin/common/models/user.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsModelUser extends AbstractCommonClubsModel
|
||||
{
|
||||
protected function getFactory()
|
||||
{
|
||||
return new CommonClubsModelFactoryUser();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->getValues()['name'];
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -13,4 +13,4 @@ ClubName: <?php echo $this->club->getMail(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getIban(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getBic(); ?> <br />
|
||||
ClubName: <?php echo $this->club->isCharitable(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getPresident(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getPresident()->getName(); ?> <br />
|
||||
|
Loading…
Reference in New Issue
Block a user