Simple controllers (offer and position) are workign in the new oo format
This commit is contained in:
55
src/admin/common/abstract/controller/mapping.php
Normal file
55
src/admin/common/abstract/controller/mapping.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
abstract class AbstractCommonClubsControllerMapping
|
||||
{
|
||||
|
||||
protected $required;
|
||||
protected $name;
|
||||
|
||||
public function __construct($name, $required = true)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->required = $required;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function requiredDataAvailable($value)
|
||||
{
|
||||
if($this->required && ($value === null || $value === ''))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JInput $input
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public abstract function getFilteredValue($input, $name);
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return boolean
|
||||
*/
|
||||
public function rawValueValid($value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,9 +40,12 @@ abstract class AbstractCommonClubsModel
|
||||
return $this->new;
|
||||
}
|
||||
|
||||
public function setValues($values)
|
||||
public function setValues($values, $unpack = false)
|
||||
{
|
||||
$this->values = $values;
|
||||
if($unpack)
|
||||
$this->values = $this->unpackExternalReferencesFromKeys($values);
|
||||
else
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
protected function setValue($key, $value)
|
||||
@@ -351,4 +354,9 @@ abstract class AbstractCommonClubsModel
|
||||
$this->setValues($vals);
|
||||
}
|
||||
|
||||
public function dataIsValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ abstract class AbstractCommonClubsModelColumn
|
||||
|
||||
protected $alias;
|
||||
protected $column;
|
||||
protected $required;
|
||||
/**
|
||||
* @var AbstractCommonClubsControllerMapping
|
||||
*/
|
||||
protected $filter;
|
||||
|
||||
public function getAlias()
|
||||
{
|
||||
@@ -20,17 +23,12 @@ abstract class AbstractCommonClubsModelColumn
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
public function isRequired()
|
||||
{
|
||||
return $this->required;
|
||||
}
|
||||
|
||||
public abstract function isSimpleType();
|
||||
|
||||
public function __construct($alias, $required = true, $column = null)
|
||||
public function __construct($alias, $filter, $column = null)
|
||||
{
|
||||
$this->alias = $alias;
|
||||
$this->required = $required;
|
||||
$this->filter = $filter;
|
||||
if(isset($column))
|
||||
$this->column = $column;
|
||||
else
|
||||
@@ -71,4 +69,9 @@ abstract class AbstractCommonClubsModelColumn
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
14
src/admin/common/controllermappings/cmp.php
Normal file
14
src/admin/common/controllermappings/cmp.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsControllerMappingCmd extends AbstractCommonClubsControllerMapping
|
||||
{
|
||||
|
||||
public function getFilteredValue($input, $name)
|
||||
{
|
||||
return $input->getCmd($name);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/admin/common/controllermappings/float.php
Normal file
14
src/admin/common/controllermappings/float.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsControllerMappingFloat extends AbstractCommonClubsControllerMapping
|
||||
{
|
||||
|
||||
public function getFilteredValue($input, $name)
|
||||
{
|
||||
return $input->getFloat($name);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/admin/common/controllermappings/int.php
Normal file
14
src/admin/common/controllermappings/int.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsControllerMappingInt extends AbstractCommonClubsControllerMapping
|
||||
{
|
||||
|
||||
public function getFilteredValue($input, $name)
|
||||
{
|
||||
return $input->getInt($name);
|
||||
}
|
||||
|
||||
}
|
||||
44
src/admin/common/controllermappings/ref.php
Normal file
44
src/admin/common/controllermappings/ref.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsControllerMappingRef extends AbstractCommonClubsControllerMapping
|
||||
{
|
||||
|
||||
/**
|
||||
* @var AbstractCommonClubsModelFactory
|
||||
*/
|
||||
protected $factory;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param AbstractCommonClubsModelFactory $factory
|
||||
* @param boolean $required
|
||||
*/
|
||||
public function __construct($name, $factory, $required = true)
|
||||
{
|
||||
parent::__construct($name, $required);
|
||||
$this->factory = $factory;
|
||||
}
|
||||
|
||||
public function getFilteredValue($input, $name)
|
||||
{
|
||||
return $input->getInt($name);
|
||||
}
|
||||
|
||||
public function rawValueValid($value)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->factory->loadById((int) $value);
|
||||
}
|
||||
catch(ElementNotFoundException $e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
14
src/admin/common/controllermappings/string.php
Normal file
14
src/admin/common/controllermappings/string.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class CommonClubsControllerMappingString extends AbstractCommonClubsControllerMapping
|
||||
{
|
||||
|
||||
public function getFilteredValue($input, $name)
|
||||
{
|
||||
return $input->getString($name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,9 +14,9 @@ class CommonClubsModelColumnRef extends AbstractCommonClubsModelColumn
|
||||
|
||||
protected $className;
|
||||
|
||||
public function __construct($alias, $className, $required=true, $column=null)
|
||||
public function __construct($alias, $className, $column=null)
|
||||
{
|
||||
parent::__construct($alias, $required, $column);
|
||||
parent::__construct($alias, $column);
|
||||
|
||||
if(empty($className))
|
||||
throw new Exception('Classname must be non-empty.');
|
||||
|
||||
@@ -8,7 +8,7 @@ class CommonClubsModelFactoryOffer extends AbstractCommonClubsModelFactory
|
||||
protected function fetchAttributes()
|
||||
{
|
||||
return array(
|
||||
new CommonClubsModelColumnString('name')
|
||||
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class CommonClubsModelFactoryPosition extends AbstractCommonClubsModelFactory
|
||||
protected function fetchAttributes()
|
||||
{
|
||||
return array(
|
||||
new CommonClubsModelColumnString('name')
|
||||
new CommonClubsModelColumnString('name', new CommonClubsControllerMappingString('Bezeichnung'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user