예제 #1
0
 /**
  * Handle delete entity object.
  *
  * @param mixed            $id
  * @param ApiEntityManager $manager
  * @throws EntityNotFoundException if an entity with the given id does not exist
  * @throws ForbiddenException if a delete operation is forbidden
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     $entity = $manager->find($id);
     if (!$entity) {
         throw new EntityNotFoundException();
     }
     $em = $manager->getObjectManager();
     $this->checkPermissions($entity, $em);
     $this->deleteEntity($entity, $em);
     $em->flush();
 }
예제 #2
0
 /**
  * @param $id
  * @param ApiEntityManager $manager
  *
  * @throws \Exception
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     /** @var ContactPhone $contactPhone */
     $contactPhone = $manager->find($id);
     if (!$this->securityFacade->isGranted('EDIT', $contactPhone->getOwner())) {
         throw new AccessDeniedException();
     }
     if ($this->contactPhoneDeleteValidator->validate($contactPhone)) {
         $em = $manager->getObjectManager();
         $em->remove($contactPhone);
         $em->flush();
     } else {
         throw new \Exception("oro.contact.phone.error.delete.more_one", 500);
     }
 }
 /**
  * Handle delete entity object.
  *
  * @param RelationIdentifier $id
  * @param ApiEntityManager   $manager
  *
  * @throws EntityNotFoundException if an entity with the given id does not exist
  * @throws ForbiddenException if a delete operation is forbidden
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     $em = $manager->getObjectManager();
     /** @var ActivityInterface $entity */
     $entity = $em->find($id->getOwnerEntityClass(), $id->getOwnerEntityId());
     if (!$entity) {
         throw new EntityNotFoundException();
     }
     $this->checkPermissions($entity, $em);
     $targetEntity = $em->find($id->getTargetEntityClass(), $id->getTargetEntityId());
     if (!$targetEntity) {
         throw new EntityNotFoundException();
     }
     $this->checkPermissionsForTargetEntity($targetEntity, $em);
     $this->activityManager->removeActivityTarget($entity, $targetEntity);
     $em->flush();
 }
 /**
  * Handle delete entity object.
  *
  * @param RelationIdentifier $id
  * @param ApiEntityManager   $manager
  *
  * @throws EntityNotFoundException if an entity with the given id does not exist
  * @throws ForbiddenException if a delete operation is forbidden
  */
 public function handleDelete($id, ApiEntityManager $manager)
 {
     $em = $manager->getObjectManager();
     /** @var ActivityInterface $entity */
     $entity = $em->find($id->getOwnerEntityClass(), $id->getOwnerEntityId());
     if (!$entity) {
         throw new EntityNotFoundException();
     }
     if (!$this->securityFacade->isGranted('EDIT', $entity)) {
         throw new ForbiddenException('has no edit permissions for activity entity');
     }
     $targetEntity = $em->find($id->getTargetEntityClass(), $id->getTargetEntityId());
     if (!$targetEntity) {
         throw new EntityNotFoundException();
     }
     if (!$this->securityFacade->isGranted('VIEW', $targetEntity)) {
         throw new ForbiddenException('has no view permissions for related entity');
     }
     $this->activityManager->removeActivityTarget($entity, $targetEntity);
     $em->flush();
 }