Added basic possibility to change the manufacturer, footprint, category and part unit of multiple parts.

This commit is contained in:
Jan Böhmer 2020-05-24 18:26:10 +02:00
parent 6f6ac0f128
commit ca74dd84f0
4 changed files with 195 additions and 2 deletions

View file

@ -21,6 +21,10 @@
namespace App\Services\Parts;
use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Part;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@ -77,6 +81,22 @@ final class PartsTableActionHandler
$this->denyAccessUnlessGranted('delete', $part);
$this->entityManager->remove($part);
break;
case 'change_category':
$this->denyAccessUnlessGranted('category.edit', $part);
$part->setCategory($this->entityManager->find(Category::class, $target_id));
break;
case 'change_footprint':
$this->denyAccessUnlessGranted('footprint.edit', $part);
$part->setFootprint($target_id === null ? null : $this->entityManager->find(Footprint::class, $target_id));
break;
case 'change_manufacturer':
$this->denyAccessUnlessGranted('manufacturer.edit', $part);
$part->setManufacturer($target_id === null ? null : $this->entityManager->find(Manufacturer::class, $target_id));
break;
case 'change_unit':
$this->denyAccessUnlessGranted('unit.edit', $part);
$part->setPartUnit($target_id === null ? null : $this->entityManager->find(MeasurementUnit::class, $target_id));
break;
default:
throw new \InvalidArgumentException('The given action is unknown! (' . $action . ')');