find elements by set
This commit is contained in:
parent
aaa494afe4
commit
b44830fa53
3 changed files with 12 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ use App\Element\CreateElementDto;
|
|||
use App\Element\Element;
|
||||
use App\Element\ElementRepository;
|
||||
use App\Exceptions\BadRequestException;
|
||||
use App\Set\Set as DomainSet;
|
||||
use App\Set\SetRepository;
|
||||
use DomainException;
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ class CreateElement
|
|||
}
|
||||
|
||||
if ($request->parentElementId === null) {
|
||||
$this->validateNoRootElementExists($request->setId);
|
||||
$this->validateNoRootElementExists($set);
|
||||
|
||||
return $this->elementRepo->create(new CreateElementDto(
|
||||
set: $set,
|
||||
|
|
@ -70,9 +71,9 @@ class CreateElement
|
|||
/**
|
||||
* @throws DomainException
|
||||
*/
|
||||
private function validateNoRootElementExists(int $setId): void
|
||||
private function validateNoRootElementExists(DomainSet $set): void
|
||||
{
|
||||
$elements = $this->elementRepo->findBySetId($setId);
|
||||
$elements = $this->elementRepo->findBySet($set);
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getParentElement() === null) {
|
||||
throw new DomainException(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue