mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
fixes #214
This commit is contained in:
parent
3aed840c77
commit
4107551a09
|
|
@ -113,12 +113,6 @@ use phpOMS\Utils\ArrayUtils;
|
|||
* One example where this could be useful is the Address/Localization model.
|
||||
* In here the country is stored by ID but you probably don't want to load an entire object and only the country name from the country table.
|
||||
*
|
||||
* @todo Orange-Management/phpOMS#214
|
||||
* Allow to define the model class
|
||||
* Currently the DataMapper uses the mapper name to find the correct model class.
|
||||
* This can remain but there should be a member variable or const which allows to define the model::class manually in case the model is different.
|
||||
* One example could be the Address/Location model in the Address module and phpOMS Localization directory.
|
||||
*
|
||||
* @todo Orange-Management/Modules#99
|
||||
* Use binds
|
||||
* Currently databinds are not used. Currently injections are possible.
|
||||
|
|
@ -237,6 +231,14 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
protected static string $table = '';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $model = '';
|
||||
|
||||
/**
|
||||
* Fields to load.
|
||||
*
|
||||
|
|
@ -2018,7 +2020,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
public static function populate(array $result, $obj = null)
|
||||
{
|
||||
$class = static::class;
|
||||
$class = \str_replace('Mapper', '', $class);
|
||||
$class = empty(static::$model) ? \str_replace('Mapper', '', $class) : static::$model; // @todo: replace str_replace with substr!!!
|
||||
|
||||
if (empty($result)) {
|
||||
$parts = \explode('\\', $class);
|
||||
|
|
@ -2450,7 +2452,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
private static function getNullModelObj()
|
||||
{
|
||||
$class = static::class;
|
||||
$class = \str_replace('Mapper', '', $class);
|
||||
$class = empty(static::$model) ? \str_replace('Mapper', '', $class) : static::$model; // @todo replace str_replace with substr!!!
|
||||
$parts = \explode('\\', $class);
|
||||
$name = $parts[$c = (\count($parts) - 1)];
|
||||
$parts[$c] = 'Null' . $name;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,26 @@ class Localization
|
|||
*/
|
||||
private array $volume = [];
|
||||
|
||||
/**
|
||||
* Country id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $id = 0;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load localization from language code
|
||||
*
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class LocalizationTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertTrue(ISO3166TwoEnum::isValidValue($this->localization->getCountry()));
|
||||
self::assertTrue(TimeZoneEnumArray::isValidValue($this->localization->getTimezone()));
|
||||
self::assertTrue(ISO639x1Enum::isValidValue($this->localization->getLanguage()));
|
||||
self::assertTrue(ISO4217Enum::isValidValue($this->localization->getCurrency()));
|
||||
self::assertTrue(ISO4217CharEnum::isValidValue($this->localization->getCurrency()));
|
||||
self::assertEquals('.', $this->localization->getDecimal());
|
||||
self::assertEquals(',', $this->localization->getThousands());
|
||||
self::assertEquals([], $this->localization->getDatetime());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user