public function handle(MassActionHandlerArgs $args) { $entityIdentifiedField = $this->getEntityIdentifierField($args); $entityName = $this->getEntityName($args); /** @var $result ResultRecordInterface */ $results = new DeletionIterableResult($args->getResults()->getSource()); foreach ($results as $result) { $entity = $this->getEntity($entityName, $result->getValue($entityIdentifiedField)); if ($this->branchService->isBranchHasTickets($entity->getId())) { return new MassActionResponse(false, $this->translator->trans('diamante.desk.branch.messages.delete.exist_tickets_error')); } } return parent::handle($args); }
public function testUpdateProperties() { $this->branchRepository->expects($this->once())->method('get')->will($this->returnValue($this->branch)); $name = 'DUMMY_NAME_UPDT'; $description = 'DUMMY_DESC_UPDT'; $this->branch->expects($this->at(0))->method('updateProperty')->with($this->equalTo('name'), $this->equalTo($name)); $this->branch->expects($this->at(1))->method('updateProperty')->with($this->equalTo('description'), $this->equalTo($description)); $this->branchRepository->expects($this->once())->method('store')->with($this->equalTo($this->branch)); $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo('Entity:DiamanteDeskBundle:Branch'))->will($this->returnValue(true)); $command = new UpdatePropertiesCommand(); $command->id = 1; $command->properties = ['name' => $name, 'description' => $description]; $this->branchServiceImpl->updateProperties($command); }
/** * Delete Branch * * @ApiDoc( * description="Delete branch", * uri="/branches/{id}.{_format}", * method="DELETE", * resource=true, * requirements={ * { * "name"="id", * "dataType"="integer", * "requirement"="\d+", * "description"="Branch Id" * } * }, * statusCodes={ * 204="Returned when successful", * 403="Returned when the user is not authorized to delete branch", * 404="Returned when the branch is not found" * } * ) * * @param int $id * @return void */ public function deleteBranch($id) { parent::deleteBranch($id); }
/** * Delete Branch * * @ApiDoc( * description="Delete branch", * uri="/branches/{id}.{_format}", * method="DELETE", * resource=true, * requirements={ * { * "name"="id", * "dataType"="integer", * "requirement"="\d+", * "description"="Branch Id" * } * }, * statusCodes={ * 204="Returned when successful", * 403="Returned when the user is not authorized to delete branch", * 404="Returned when the branch is not found", * 409="Branch has tickets and can't be deleted" * } * ) * * @param int $id * @throws BranchHasTicketsException */ public function deleteBranch($id) { if (!parent::isBranchHasTickets($id)) { parent::deleteBranch($id); } else { throw new BranchHasTicketsException("Branch has tickets and can't be deleted"); } }