This commit is contained in:
mcndave committed 2023-11-03 08:26:16 -04:00
commit 531908b04c
12 files changed
+93 -51

No files matched your search

+10 -13
View File
@@ -62,7 +62,7 @@ trait EntityTrait {
$data = json_decode($value, true);
if (json_last_error() !== \JSON_ERROR_NONE) {
throw new \Exception(sprintf("JSON error while decoding in EntityTrait : '%s' given %s with field %s", json_last_error_msg(), $value, json_encode($field)));
throw new \Exception(sprintf("JSON error while decoding in EntityTrait : '%s' given %s", json_last_error_msg(), $value));
}
$this->{$field['name']} = $data;
@@ -112,7 +112,7 @@ trait EntityTrait {
$this->entityLoadedDataset = array_change_key_case($dataset, \CASE_LOWER);
}
elseif ($overwriteDataset) {
$this->entityLoadedDataset = array_change_key_case($dataset, \CASE_LOWER) + $this->entityLoadedDataset;
$this->entityLoadedDataset = iterator_to_array(array_change_key_case($dataset, \CASE_LOWER)) + $this->entityLoadedDataset;
}
}
@@ -123,11 +123,9 @@ trait EntityTrait {
public function resetVirtualProperties() : self
{
foreach($this->resolveEntity()->properties as $prop => $property) {
if ( empty($property['builtin']) ) {
foreach($property['tags'] as $tag) {
if ( in_array(strtolower($tag['tag']), [ 'relation', 'join', 'virtual' ] ) ) {
unset($this->$prop);
}
foreach($property['tags'] as $tag) {
if ( in_array(strtolower($tag['tag']), [ 'relation', 'join', 'virtual' ] ) ) {
unset($this->$prop);
}
}
}
@@ -264,10 +262,6 @@ trait EntityTrait {
#[Ignore]
public function __clone()
{
foreach($this as $prop) {
}
if ( null !== $pkField = $this->resolveEntity()->getPrimaryKeyField($this) ) {
$key = key($pkField);
@@ -309,9 +303,12 @@ trait EntityTrait {
}
#[Ignore]
public static function field($name, null|string|bool $alias = Repository::DEFAULT_ALIAS) : EntityField
public static function field($name, null|string|false $alias = Repository::DEFAULT_ALIAS) : EntityField
{
return new EntityField(static::class, $name, $alias ? Ulmus::repository(static::class)->adapter->adapter()->escapeIdentifier($alias, Adapter\AdapterInterface::IDENTIFIER_FIELD) : ( $alias === false ? '' : Repository::DEFAULT_ALIAS ), Ulmus::resolveEntity(static::class));
$default = ( $alias === false ? '' : Repository::DEFAULT_ALIAS ); # bw compatibility, to be deprecated
return new EntityField(static::class, $name, $alias ? Ulmus::repository(static::class)->adapter->adapter()->escapeIdentifier($alias, Adapter\AdapterInterface::IDENTIFIER_FIELD) : $default, Ulmus::resolveEntity(static::class));
}
#[Ignore]