Commit 8866af9a authored by Bernhard Schussek's avatar Bernhard Schussek

Added ORMRepository::removeMultiple()

parent 67697ed9
Pipeline #19350 passed with stage
in 1 minute and 38 seconds
......@@ -292,6 +292,35 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
);
}
/**
* {@inheritdoc}
*/
public function removeMultiple(array $ids): int
{
$removed = 0;
$entityName = $this->getEntityName();
foreach ($ids as $id) {
$reference = $this->_em->getReference($entityName, $id);
try {
$this->_em->remove($reference);
++$removed;
} catch (EntityNotFoundException $e) {
// getReference() adds the reference to the identity map, so we need
// to remove it again
$this->_em->detach($reference);
}
}
if ($removed > 0) {
$this->_em->flush($reference);
}
return $removed;
}
/**
* {@inheritdoc}
*/
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c63f0630d4e3e60359dc93726323ba27",
"content-hash": "22b888086d547949b9b73d35b5d20cee",
"packages": [
{
"name": "cwd/common",
......@@ -37,13 +37,14 @@
},
{
"name": "cwd/data-bundle",
"version": "1.1.0",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://gitlab.cwd.at/cwd/data-bundle.git",
"reference": "87c2c27ae0b165220ea901306f9ab7701384783e"
"reference": "6c715b6e4d833599f3a749d69dbd2a8fde554ac7"
},
"require": {
"cwd/common": "^1.1",
"doctrine/annotations": "^1.6",
"doctrine/inflector": "^1.3",
"php": ">=7.1.0",
......@@ -55,8 +56,10 @@
"webmozart/assert": "^1.1"
},
"require-dev": {
"doctrine/lexer": "^1.0",
"friendsofphp/php-cs-fixer": "^2.13",
"phpunit/phpunit": "^6.4"
"phpunit/phpunit": "^6.4",
"ramsey/uuid": "^3.8"
},
"suggest": {
"ramsey/uuid": "For using UUIDs as IDs"
......@@ -77,7 +80,7 @@
}
],
"description": "The base bundle of the cwd.at GmbH for managing repository data",
"time": "2019-01-11T18:27:24+00:00"
"time": "2019-01-27T16:16:17+00:00"
},
{
"name": "doctrine/annotations",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment