Exemplo n.º 1
0
 /**
  * @return array
  */
 protected function getChoices()
 {
     $transports = $this->emailTransportProvider->getTransports();
     $choices = array();
     foreach ($transports as $transport) {
         $choices[$transport->getName()] = $transport->getLabel();
     }
     return $choices;
 }
Exemplo n.º 2
0
 /**
  * @param string $selectedTransportName
  * @return TransportInterface
  */
 protected function getSelectedTransport($selectedTransportName)
 {
     if ($selectedTransportName) {
         $selectedTransport = $this->emailTransportProvider->getTransportByName($selectedTransportName);
     } else {
         $transportChoices = $this->emailTransportProvider->getTransports();
         $selectedTransport = reset($transportChoices);
     }
     return $selectedTransport;
 }
Exemplo n.º 3
0
 /**
  * @param FormBuilderInterface $builder
  */
 protected function addTransport(FormBuilderInterface $builder)
 {
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $options = ['label' => 'orocrm.campaign.emailcampaign.transport.label', 'required' => true, 'mapped' => false];
         /** @var EmailCampaign $data */
         $data = $event->getData();
         if ($data) {
             $choices = $this->emailTransportProvider->getVisibleTransportChoices();
             $currentTransportName = $data->getTransport();
             if (!array_key_exists($currentTransportName, $choices)) {
                 $currentTransport = $this->emailTransportProvider->getTransportByName($currentTransportName);
                 $choices[$currentTransport->getName()] = $currentTransport->getLabel();
                 $options['choices'] = $choices;
             }
         }
         $form = $event->getForm();
         $form->add('transport', 'orocrm_campaign_email_transport_select', $options);
     });
 }
Exemplo n.º 4
0
 /**
  * @param EmailCampaign $emailCampaign
  */
 public function setEmailCampaign(EmailCampaign $emailCampaign)
 {
     $this->emailCampaign = $emailCampaign;
     $this->transport = $this->emailTransportProvider->getTransportByName($emailCampaign->getTransport());
 }
Exemplo n.º 5
0
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Transport test is unknown
  */
 public function testGetTransportException()
 {
     $provider = new EmailTransportProvider();
     $provider->getTransportByName('test');
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['choices' => $this->emailTransportProvider->getVisibleTransportChoices()]);
 }