mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-16 08:28: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.
|
* 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.
|
* 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
|
* @todo Orange-Management/Modules#99
|
||||||
* Use binds
|
* Use binds
|
||||||
* Currently databinds are not used. Currently injections are possible.
|
* Currently databinds are not used. Currently injections are possible.
|
||||||
|
|
@ -237,6 +231,14 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*/
|
*/
|
||||||
protected static string $table = '';
|
protected static string $table = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model to use by the mapper.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static string $model = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields to load.
|
* Fields to load.
|
||||||
*
|
*
|
||||||
|
|
@ -2018,7 +2020,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
public static function populate(array $result, $obj = null)
|
public static function populate(array $result, $obj = null)
|
||||||
{
|
{
|
||||||
$class = static::class;
|
$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)) {
|
if (empty($result)) {
|
||||||
$parts = \explode('\\', $class);
|
$parts = \explode('\\', $class);
|
||||||
|
|
@ -2450,7 +2452,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
private static function getNullModelObj()
|
private static function getNullModelObj()
|
||||||
{
|
{
|
||||||
$class = static::class;
|
$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);
|
$parts = \explode('\\', $class);
|
||||||
$name = $parts[$c = (\count($parts) - 1)];
|
$name = $parts[$c = (\count($parts) - 1)];
|
||||||
$parts[$c] = 'Null' . $name;
|
$parts[$c] = 'Null' . $name;
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,26 @@ class Localization
|
||||||
*/
|
*/
|
||||||
private array $volume = [];
|
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
|
* Load localization from language code
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class LocalizationTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertTrue(ISO3166TwoEnum::isValidValue($this->localization->getCountry()));
|
self::assertTrue(ISO3166TwoEnum::isValidValue($this->localization->getCountry()));
|
||||||
self::assertTrue(TimeZoneEnumArray::isValidValue($this->localization->getTimezone()));
|
self::assertTrue(TimeZoneEnumArray::isValidValue($this->localization->getTimezone()));
|
||||||
self::assertTrue(ISO639x1Enum::isValidValue($this->localization->getLanguage()));
|
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->getDecimal());
|
||||||
self::assertEquals(',', $this->localization->getThousands());
|
self::assertEquals(',', $this->localization->getThousands());
|
||||||
self::assertEquals([], $this->localization->getDatetime());
|
self::assertEquals([], $this->localization->getDatetime());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user