public function setDefaultOptions(OptionsResolverInterface $resolver) { $choices = array(); foreach ($this->branchService->getAllbranches() as $branch) { $choices[$branch->getId()] = $branch->getName(); } $resolver->setDefaults(array('choices' => $choices)); }
public function buildForm(FormBuilderInterface $builder, array $options) { $choices = array(); foreach ($this->branchService->getAllbranches() as $branch) { $choices[$branch->getId()] = $branch->getName(); } $brunchForDelete = $options['data']['id']; if (isset($choices[$brunchForDelete])) { unset($choices[$brunchForDelete]); } $builder->add($builder->create('newBranch', 'choice', array('label' => 'diamante.desk.branch.messages.delete.select', 'required' => true, 'attr' => array('style' => "width:110px"), 'choices' => $choices)))->add($builder->create('moveTickets', 'checkbox', array('label' => 'diamante.desk.branch.messages.delete.move', 'required' => false))); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $choices = []; foreach ($this->branchService->getAllbranches() as $branch) { $choices[$branch->getId()] = $branch->getName(); } if (isset($options['data']['values'])) { $removeBranches = explode(',', $options['data']['values']); $flipedBranches = array_flip($removeBranches); $choices = array_diff_key($choices, $flipedBranches); } $builder->add($builder->create('newBranch', 'choice', ['label' => 'diamante.desk.branch.messages.delete.select', 'required' => true, 'attr' => ['style' => "width:110px"], 'choices' => $choices]))->add($builder->create('moveMassTickets', 'checkbox', ['label' => 'diamante.desk.branch.messages.delete.move', 'required' => false]))->add($builder->create('removeBranches', 'hidden', ['required' => false, 'data' => $options['data']['values']])); }
public function testProcessWhenMessageWithoutReferenceWithoutDefaultBranch() { $message = new Message(self::DUMMY_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_SUBJECT, self::DUMMY_CONTENT, $this->getDummyFrom(), self::DUMMY_MESSAGE_TO); $assigneeId = 1; $diamanteUser = $this->getReporter(1); $this->userService->expects($this->once())->method('getUserByEmail')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue($diamanteUser)); $this->configManager->expects($this->once())->method('get')->with($this->equalTo('diamante_desk.default_branch'))->will($this->returnValue(1)); $this->branchService->expects($this->once())->method('getBranch')->with($this->equalTo(1))->will($this->returnValue($this->defaultBranch)); $this->defaultBranch->expects($this->any())->method('getDefaultAssigneeId')->will($this->returnValue($assigneeId)); $reporter = $this->getReporter($diamanteUser->getId()); $this->messageReferenceService->expects($this->once())->method('createTicket')->with($this->equalTo($message->getMessageId()), self::DUMMY_BRANCH_ID, $message->getSubject(), $message->getContent(), $reporter, $assigneeId); $this->ticketStrategy->process($message); }