- Bugfix within PdoObject and Repository
- Added some utilities methods to EntityCollection
This commit is contained in:
1 parent
d03f9ece36
commit
4b29232543
3 files changed
+13
-4
No files matched your search
+6
-3
@@ -105,9 +105,7 @@ class Repository
|
||||
throw new \Exception(sprintf("No primary key found for entity %s", $this->entityClass));
|
||||
}
|
||||
|
||||
$diff = array_diff_assoc($dataset, $entity->entityGetDataset(true));
|
||||
|
||||
if ( [] !== $diff ) {
|
||||
if ( [] !== $diff = $this->generateDatasetDiff($entity) ) {
|
||||
$pkField = key($primaryKeyDefinition);
|
||||
$pkFieldName = $primaryKeyDefinition[$pkField]->name ?? $pkField;
|
||||
$this->where($pkFieldName, $dataset[$pkFieldName]);
|
||||
@@ -128,6 +126,11 @@ class Repository
|
||||
}
|
||||
}
|
||||
|
||||
public function generateDatasetDiff(object $entity) : array
|
||||
{
|
||||
return array_diff_assoc( array_change_key_case($entity->toArray()), array_change_key_case($entity->entityGetDataset(true)) );
|
||||
}
|
||||
|
||||
public function yieldAll() : \Generator
|
||||
{
|
||||
|
||||
|
||||
Reference in new issue
Block a user