- Worked on SQLite adapter mostly
This commit is contained in:
1 parent
8e0dce3e71
commit
07ae8faaac
4 files changed
+18
-7
No files matched your search
+8
-5
@@ -141,7 +141,7 @@ trait EntityTrait {
|
||||
return $this->entityFillFromDataset($dataset);
|
||||
}
|
||||
|
||||
public function entityGetDataset(bool $includeRelations = false, bool $returnSource = false) : array
|
||||
public function entityGetDataset(bool $includeRelations = false, bool $returnSource = false, bool $rewriteValue = true) : array
|
||||
{
|
||||
if ( $returnSource ) {
|
||||
return $this->entityLoadedDataset;
|
||||
@@ -155,7 +155,10 @@ trait EntityTrait {
|
||||
$annotation = $entityResolver->searchFieldAnnotation($key, [ Attribute\Property\Field::class, Field::class ]);
|
||||
|
||||
if ( isset($this->$key) ) {
|
||||
$dataset[$annotation->name ?? $key] = static::repository()->adapter->adapter()->writableValue($this->$key);
|
||||
$dataset[$annotation->name ?? $key] = $rewriteValue?
|
||||
static::repository()->adapter->adapter()->writableValue($this->$key)
|
||||
:
|
||||
$this->$key;
|
||||
}
|
||||
elseif ( $field['nullable'] ) {
|
||||
$dataset[$annotation->name ?? $key] = null;
|
||||
@@ -165,7 +168,7 @@ trait EntityTrait {
|
||||
# @TODO Must fix recursive bug !
|
||||
if ($includeRelations) {
|
||||
foreach($entityResolver->properties as $name => $field){
|
||||
$relation = $entityResolver->searchFieldAnnotation($key, [ Attribute\Property\Relation::class. Relation::class ] );
|
||||
$relation = $entityResolver->searchFieldAnnotation($name, [ Attribute\Property\Relation::class, Relation::class ] );
|
||||
|
||||
if ( $relation && isset($this->$name) && ($relation->entity ?? $relation->bridge) !== static::class ) {
|
||||
if ( null !== $value = $this->$name ?? null ) {
|
||||
@@ -192,7 +195,7 @@ trait EntityTrait {
|
||||
#[Ignore]
|
||||
public function toArray($includeRelations = false, array $filterFields = null) : array
|
||||
{
|
||||
$dataset = $this->entityGetDataset($includeRelations);
|
||||
$dataset = $this->entityGetDataset($includeRelations, false, false);
|
||||
|
||||
return $filterFields ? array_intersect_key($dataset, array_flip($filterFields)) : $dataset;
|
||||
}
|
||||
@@ -275,7 +278,7 @@ trait EntityTrait {
|
||||
#[Ignore]
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->entityGetDataset();
|
||||
return $this->entityGetDataset(true, false, false);
|
||||
}
|
||||
|
||||
#[Ignore]
|
||||
|
||||
Reference in new issue
Block a user