src/Products/NotificationsBundle/Form/Forms/Messages/MessageChannelsForm.php line 25

Open in your IDE?
  1. <?php
  2. namespace Products\NotificationsBundle\Form\Forms\Messages;
  3. use App\Entity\System\School;
  4. use Cms\CoreBundle\Form\Type\DateTimeType;
  5. use Cms\FrontendBundle\Service\ResolverManager;
  6. use Products\NotificationsBundle\Entity\Notifications\Message;
  7. use Products\NotificationsBundle\Form\Type\BannerChoiceType;
  8. use Products\NotificationsBundle\Form\Type\FancyEntityType;
  9. use Products\NotificationsBundle\Form\Type\MessageChoiceType;
  10. use Products\NotificationsBundle\Form\Type\SteppedDateTimeType;
  11. use Symfony\Component\Form\AbstractType;
  12. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  13. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\Form\FormInterface;
  17. use Symfony\Component\Form\FormView;
  18. /**
  19.  * Class MessageChannelsForm
  20.  * @package Products\NotificationsBundle\Form\Forms\Messages
  21.  */
  22. class MessageChannelsForm extends AbstractType
  23. {
  24.     /**
  25.      * @var ResolverManager
  26.      */
  27.     protected ResolverManager $rm;
  28.     /**
  29.      * @param ResolverManager $rm
  30.      */
  31.     public function __construct(ResolverManager $rm)
  32.     {
  33.         $this->rm $rm;
  34.     }
  35.     /**
  36.      * {@inheritDoc}
  37.      */
  38.     public function finishView(FormView $viewFormInterface $form, array $options): void
  39.     {
  40.         $view->children['action']->setRendered();
  41.     }
  42.     /**
  43.      * {@inheritDoc}
  44.      */
  45.     public function buildForm(FormBuilderInterface $builder, array $options): void
  46.     {
  47.         /** @var Message $message */
  48.         $message $builder->getData();
  49.         $builder
  50.             ->add('scheduled'ChoiceType::class, [
  51.                 'label' => false,
  52.                 'expanded' => true,
  53.                 'choices' => [
  54.                     'Send Now' => false,
  55.                     'Schedule for Later' => true,
  56.                 ],
  57.                 'data' => false,
  58.                 'mapped' => false,
  59.                 'required' => true,
  60.             ])
  61.             ->add('scheduledAt'DateTimeType::class, [
  62.                 'widget' => 'single_text',
  63.                 'mapped' => false,
  64.                 'required' => false,
  65.                 'show_timezone' => false,
  66.             ])
  67.             ->add('branding'FancyEntityType::class, [
  68.                 'required' => false,
  69.                 'placeholder' => "Select branding",
  70.                 'empty_data' => null,
  71.                 'label_tooltip' => true,
  72.                 'class' => School::class,
  73.                 'choice_label' => 'name',
  74.                 'choices' => array_values(array_filter($this->rm->getSchoolResolver()->resolveSchoolsByLists($message->getListsAsArray()))) ?: [$this->rm->getSchoolResolver()->resolveDistrictByTenant($message)],
  75.             ])
  76.             ->add('action'HiddenType::class, [
  77.                 'mapped' => false,
  78.                 'required' => false,
  79.             ])
  80.             ->add('channels'ChannelsType::class, [
  81.                 'required' => false,
  82.             ])
  83.             // WEBSITE CHANNEL
  84.             ->add('websiteEndDateTime'SteppedDateTimeType::class, [
  85.                 'label_tooltip' => 'Select the date and time your website alert should expire from the website.',
  86.             ])
  87.             ->add('websiteLevel'MessageChoiceType::class, [
  88.                 'label_tooltip' => "Select the priority of your website alert. <a target='blank' href='https://help.schoolnow.com/kb/how-do-i-add-an-emergency-alert'>Learn more</a>",
  89.             ])
  90.             ->add('websiteBehavior'BannerChoiceType::class, [
  91.                 'label_tooltip' => "Selecting banner with popup will require the user to dismiss the alert. <a target='blank' href='https://help.schoolnow.com/kb/how-do-i-add-an-emergency-alert'>Learn more</a>",
  92.             ])
  93.             // FACEBOOK CHANNEL
  94.             ->add('facebookNote'TextType::class, [
  95.                 'required' => false,
  96.                 'label_tooltip' => true,
  97.             ])
  98.             // TWITTER CHANNEL
  99.             ->add('twitterNote'TextType::class, [
  100.                 'required' => false,
  101.                 'label_tooltip' => true,
  102.             ])
  103.             ->add('translations'MessageTranslationsForm::class, [
  104.                 'label_tooltip' => true,
  105.                 'data' => $builder->getData(),
  106.                 'mapped' => false,
  107.             ])
  108.         ;
  109.     }
  110. }