public function setInventoryAudit(InventoryAudit $inventoryAudit) { if ($inventoryAudit === null) { $this->inventoryAudit = null; $inventoryAudit->removeInventoryTravelerIdAudit($this); } else { $this->inventoryAudit = $inventoryAudit; $inventoryAudit->addInventoryTravelerIdAudit($this); } return $this; }
public function setInventoryAudit(InventoryAudit $inventoryAudit = null) { if ($inventoryAudit === null) { if ($this->inventoryAudit->contains($this)) { $this->inventoryAudit->removeInventorySkuAudit($this); } $this->inventoryAudit = null; } else { $this->inventoryAudit = $inventoryAudit; $inventoryAudit->addInventorySkuAudit($this); } return $this; }
/** * @Rest\Post("/inventory_audit") * @Rest\View(template=":default:index.html.twig",serializerEnableMaxDepthChecks=true, serializerGroups={"Default"}) * @ParamConverter("inventoryAudit", converter="fos_rest.request_body") */ public function createInventoryAuditAction(\AppBundle\Entity\InventoryAudit $inventoryAudit) { $inventoryAudit->setByUser($this->getUser()); if ($this->get('security.authorization_checker')->isGranted('CREATE', $inventoryAudit) and $inventoryAudit->isOwnedByOrganization($this->getUser()->getOrganization())) { $em = $this->getDoctrine()->getManager(); $inventoryAudit->setStartedAt(new \DateTime()); $inventoryAudit->getForBin()->setIsLocked(true); $em->persist($inventoryAudit); $em->flush(); $this->updateAclByRoles($inventoryAudit, ['ROLE_USER' => 'view', 'ROLE_ADMIN' => 'operator']); return $inventoryAudit; } else { throw $this->createAccessDeniedException(); } }