Skip to content

Commit

Permalink
Merge 3ca1fcf into 2426c46
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavpavek committed Jan 15, 2020
2 parents 2426c46 + 3ca1fcf commit 3b7fb65
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
18 changes: 12 additions & 6 deletions src/Model/IModel.php
Expand Up @@ -55,24 +55,30 @@ public function getMetadataStorage(): MetadataStorage;
* Persist the entity with cascade.
*/
public function persist(IEntity $entity, bool $withCascade = true): IEntity;


/**
* Persist the entity with cascade and flushes the model.
*/
public function persistAndFlush(IEntity $entity): IEntity;


/**
* Removes the entity with cascade.
*/
public function remove(IEntity $entity, bool $withCascade = true): IEntity;


/**
* Flushes all persisted changes in repositories.
* Removes the entity with cascade and flushes the model.
*/
public function flush(): void;
public function removeAndFlush(IEntity $entity, bool $withCascade = true): IEntity;


/**
* Persist the entity with cascade and flushes the model.
* Flushes all persisted changes in repositories.
*/
public function persistAndFlush(IEntity $entity): IEntity;
public function flush(): void;


/**
Expand Down
28 changes: 19 additions & 9 deletions src/Model/Model.php
Expand Up @@ -131,6 +131,16 @@ public function persist(IEntity $entity, bool $withCascade = true): IEntity
}


/** {@inheritdoc} */
public function persistAndFlush(IEntity $entity): IEntity
{
$this->persist($entity);
$this->flush();
return $entity;
}


/** {@inheritdoc} */
public function remove(IEntity $entity, bool $withCascade = true): IEntity
{
$queuePersist = $queueRemove = [];
Expand All @@ -149,6 +159,15 @@ public function remove(IEntity $entity, bool $withCascade = true): IEntity
}
return $entity;
}


/** {@inheritdoc} */
public function removeAndFlush(IEntity $entity, bool $withCascade = true): IEntity
{
$this->remove($entity, $withCascade);
$this->flush();
return $entity;
}


/** {@inheritdoc} */
Expand All @@ -166,15 +185,6 @@ public function flush(): void
}


/** {@inheritdoc} */
public function persistAndFlush(IEntity $entity): IEntity
{
$this->persist($entity);
$this->flush();
return $entity;
}


/** {@inheritdoc} */
public function clear(): void
{
Expand Down

0 comments on commit 3b7fb65

Please sign in to comment.