コード例 #1
0
ファイル: MailboxType.php プロジェクト: antrampa/platform
 /**
  * PreSet event handler.
  *
  * Adds appropriate process field to form based on set value.
  *
  * @param FormEvent $event
  */
 public function preSet(FormEvent $event)
 {
     /** @var Mailbox $data */
     $data = $event->getData();
     $form = $event->getForm();
     /*
      * Process types are selected based on mailbox, some processes are for example not available in some
      * organizations.
      */
     FormUtils::replaceField($form, 'processType', ['choices' => $this->storage->getProcessTypeChoiceList($data)]);
     if ($data === null) {
         return;
     }
     /*
      * If data has already selected some kind of process type, make it default value for field.
      */
     $processType = null;
     if (null !== ($processEntity = $data->getProcessSettings())) {
         $processType = $processEntity->getType();
     }
     FormUtils::replaceField($form, 'processType', ['data' => $processType]);
     /*
      * Add appropriate field for selected process type to form.
      */
     $this->addProcessField($form, $processType);
     /*
      * Configure user field to display only users from organization which mailbox belongs to.
      */
     $this->configureUserField($form, $data);
 }
コード例 #2
0
ファイル: MailboxType.php プロジェクト: 2ndkauboy/platform
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('label', 'text', ['required' => true, 'label' => 'oro.email.mailbox.label.label', 'constraints' => [new NotNull()]]);
     $builder->add('email', 'oro_email_email_address', ['required' => true, 'label' => 'oro.email.mailbox.email.label', 'constraints' => [new NotNull(), new Email()]]);
     $builder->add('origin', 'oro_imap_configuration');
     $builder->add('processType', 'choice', ['label' => 'oro.email.mailbox.process.type.label', 'choices' => $this->storage->getProcessTypeChoiceList(), 'required' => false, 'mapped' => false, 'empty_value' => 'oro.email.mailbox.process.default.label', 'empty_data' => null]);
     $builder->add('authorizedUsers', 'oro_user_multiselect', ['label' => 'oro.user.entity_plural_label']);
     $builder->add('authorizedRoles', 'oro_role_multiselect', ['label' => 'oro.user.role.entity_plural_label']);
     $builder->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'preSet']);
     $builder->addEventListener(FormEvents::PRE_SUBMIT, [$this, 'preSubmit']);
 }