- Minor code cleaning
This commit is contained in:
1 parent
75fb7ba155
commit
7954d83f52
1 file changed
+2
-8
+2
-8
@@ -158,19 +158,14 @@ class Repository implements RepositoryInterface
|
||||
throw new \Exception("Your entity class `" . get_class($entity) . "` cannot match entity type of repository `{$this->entityClass}`");
|
||||
}
|
||||
|
||||
$primaryKeyDefinition = Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField();
|
||||
|
||||
if ( $primaryKeyDefinition !== null ) {
|
||||
if ($primaryKeyDefinition = Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField()) {
|
||||
$pkField = key($primaryKeyDefinition);
|
||||
|
||||
$this->eventExecute(Event\Query\Delete::class, $this, $entity);
|
||||
|
||||
return $this->deleteFromPk($entity->$pkField);
|
||||
}
|
||||
else {
|
||||
$compoundKeyFields = Ulmus::resolveEntity($this->entityClass)->getCompoundKeyFields();
|
||||
|
||||
if ($compoundKeyFields) {
|
||||
elseif ($compoundKeyFields = Ulmus::resolveEntity($this->entityClass)->getCompoundKeyFields()) {
|
||||
$this->eventExecute(Event\Query\Delete::class, $this, $entity);
|
||||
|
||||
return $this->deleteFromCompoundKeys(array_combine($compoundKeyFields->column, array_map(fn($column) => $entity->$column, $compoundKeyFields->column)));
|
||||
@@ -179,7 +174,6 @@ class Repository implements RepositoryInterface
|
||||
throw new \Exception(sprintf("No primary key found for entity %s", $this->entityClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function destroyAll(EntityCollection $collection) : void
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user