Removed some bugs in abstract class, added testcase
This commit is contained in:
parent
b3e28d7884
commit
b868f0fe86
@ -127,7 +127,7 @@ abstract class AbstractCommonClubsModel
|
||||
{
|
||||
foreach($this->getFactory()->getAttributes() as $k => $v)
|
||||
{
|
||||
if($v['type'] !== 'ref')
|
||||
if(empty($v['type']) || $v['type'] !== 'ref')
|
||||
continue;
|
||||
|
||||
if(empty($v['ref']))
|
||||
@ -148,7 +148,7 @@ abstract class AbstractCommonClubsModel
|
||||
return $factory->loadById($value);
|
||||
}
|
||||
|
||||
private static const CLASSNAME_MAP = array(
|
||||
private const CLASSNAME_MAP = array(
|
||||
|
||||
);
|
||||
|
||||
|
@ -62,7 +62,7 @@ abstract class AbstractCommonClubsModelFactory
|
||||
// }
|
||||
|
||||
$q->select('main.id AS id');//->select($columns);
|
||||
$q->from($this->getTableName(), 'main');
|
||||
$q->from($this->getTableName() . ' AS main');
|
||||
|
||||
// TODO Joins
|
||||
|
||||
@ -72,13 +72,11 @@ abstract class AbstractCommonClubsModelFactory
|
||||
$db->setQuery($q);
|
||||
$db->execute();
|
||||
|
||||
$it = $db->getIterator();
|
||||
$rows = $db->loadAssocList();
|
||||
$ret = array();
|
||||
while($it->valid())
|
||||
foreach($rows as $row)
|
||||
{
|
||||
$row = $it->current();
|
||||
$ret[] = $this->generateObject($row);
|
||||
$it->next();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@ -109,7 +107,7 @@ abstract class AbstractCommonClubsModelFactory
|
||||
protected function generateObject($row)
|
||||
{
|
||||
$obj = $this->generatePlainObject($row['id']);
|
||||
$obj->marksAsNew(false);
|
||||
$obj->markAsNew(false);
|
||||
|
||||
//unset($row['id']);
|
||||
//$obj->setValues($row);
|
@ -11,4 +11,50 @@ class CommonClubsModelClub extends AbstractCommonClubsModel
|
||||
return new CommonClubsModelFactoryClub();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->getValues()['name'];
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->getValues()['address'];
|
||||
}
|
||||
|
||||
public function getCity()
|
||||
{
|
||||
return $this->getValues()['city'];
|
||||
}
|
||||
|
||||
public function getHomepage()
|
||||
{
|
||||
return $this->getValues()['homepage'];
|
||||
}
|
||||
|
||||
public function getMail()
|
||||
{
|
||||
return $this->getValues()['mail'];
|
||||
}
|
||||
|
||||
public function getIban()
|
||||
{
|
||||
return $this->getValues()['iban'];
|
||||
}
|
||||
|
||||
public function getBic()
|
||||
{
|
||||
return $this->getValues()['bic'];
|
||||
}
|
||||
|
||||
public function isCharitable()
|
||||
{
|
||||
return $this->getValues()['charitable'];
|
||||
}
|
||||
|
||||
public function getPresident()
|
||||
{
|
||||
return $this->getValues()['president'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
16
src/admin/views/test/tmpl/default.php
Normal file
16
src/admin/views/test/tmpl/default.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
||||
|
||||
ClubName: <?php echo $this->club->getName(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getAddress(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getCity(); ?> <br />
|
||||
ClubName: <?php echo $this->club->getHomepage(); ?> <br />
|
||||
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 />
|
35
src/admin/views/test/view.html.php
Normal file
35
src/admin/views/test/view.html.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\CMS\MVC\View\HtmlView;
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JLoader::register("ClubsControllerClub", JPATH_ROOT . "/administrator/components/com_clubs/controllers/club.php");
|
||||
|
||||
class ClubsViewTest extends HtmlView
|
||||
{
|
||||
function display($tpl = null)
|
||||
{
|
||||
ToolbarHelper::title('Test');
|
||||
|
||||
$factory = new CommonClubsModelFactoryClub();
|
||||
$this->clubs = $factory->loadElements();
|
||||
|
||||
$this->club = $this->clubs[0];
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
protected function getViewName()
|
||||
{
|
||||
return 'club';
|
||||
}
|
||||
protected function getElementController()
|
||||
{
|
||||
return new ClubsControllerClub();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user