Skip to content

Commit

Permalink
Improved user datagrid
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed Apr 10, 2024
1 parent 44ae9cf commit 1f258f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/Collection/ReadBuilder/ReadBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ public function toArray(): array
return array_values($cols);
}

public function dump(): void
{
dumpe($this->build()->toArray());
}

protected function addIdColumnIfNotExists(): void
{
if (!array_key_exists('id', $this->columns)) {
Expand Down
5 changes: 0 additions & 5 deletions src/Collection/WriteBuilder/WriteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,6 @@ public function getSerializedValues(): array
return $values;
}

public function dump(): void
{
dumpe($this->build()->toArray());
}

private function recreateRules(IField $field): IField
{
$rules = $field->getRules();
Expand Down
11 changes: 10 additions & 1 deletion src/Http/Request/Collection/DeleteRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Megio\Http\Request\Collection;

use Doctrine\DBAL\Exception\ConstraintViolationException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Megio\Collection\RecipeFinder;
use Megio\Event\Collection\EventType;
use Megio\Http\Request\Request;
Expand Down Expand Up @@ -74,7 +76,14 @@ public function process(array $data): Response
return $dispatcher->getResponse();
}

$qb->delete()->getQuery()->execute();
try {
$qb->delete()->getQuery()->execute();
} catch (ConstraintViolationException $e) {
$response = $this->error([$e->getMessage()], 400);
$event = new OnExceptionEvent(EventType::DELETE, $data, $recipe, $e, $this->request, $response);
$dispatcher = $this->dispatcher->dispatch($event, Events::ON_EXCEPTION->value);
return $dispatcher->getResponse();
}

$result = [
'ids' => $data['ids'],
Expand Down

0 comments on commit 1f258f7

Please sign in to comment.