Skip to content

Backup

What are backups

Backups are copy of an entity linked with original entity.

Create backup

// Get post
$postManager = $managerFactory->get(Post::class);
$post = $postManager->findOne(["id" => $postId], [["comments"]]);

$post->backup();

Use backup

Simply use getBackup to retreive entity as it where on backup call.

// Get post
$postManager = $managerFactory->get(Post::class);
$post = $postManager->findOne(["id" => $postId], [["comments"]]);

$post->backup();

Check modified since backup

You can check if entity has been modified since back by using method :

$postManager = $managerFactory->get(Post::class);
$post = $postManager->findOne(["id" => $postId], [["comments"]]);

$post->backup();

$form = $postManager->getForm();

$form->fillWithArray($requestBody);

$form->hydrate($post);

if ($post->modifiedSinceBackup()) {
    $post->persist();
}