Skip to content

Commit

Permalink
Using the right form name that is passed into Mautic.launchBuilder() …
Browse files Browse the repository at this point in the history
…method.

Plus removing unused dependency and some CS improvements
  • Loading branch information
escopecz committed Apr 15, 2020
1 parent 9828415 commit bf569a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
1 change: 0 additions & 1 deletion app/bundles/EmailBundle/Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@
'arguments' => [
'translator',
'doctrine.orm.entity_manager',
'request_stack',
'mautic.stage.model.stage',
],
],
Expand Down
49 changes: 14 additions & 35 deletions app/bundles/EmailBundle/Form/Type/EmailType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Translation\TranslatorInterface;

Expand All @@ -58,11 +57,6 @@ class EmailType extends AbstractType
*/
private $em;

/**
* @var RequestStack
*/
private $requestStack;

/**
* @var StageModel
*/
Expand All @@ -71,13 +65,11 @@ class EmailType extends AbstractType
public function __construct(
TranslatorInterface $translator,
EntityManager $entityManager,
RequestStack $requestStack,
StageModel $stageModel
) {
$this->translator = $translator;
$this->em = $entityManager;
$this->requestStack = $requestStack;
$this->stageModel = $stageModel;
$this->translator = $translator;
$this->em = $entityManager;
$this->stageModel = $stageModel;
}

public function buildForm(FormBuilderInterface $builder, array $options)
Expand Down Expand Up @@ -383,7 +375,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]
);

$request = $this->requestStack->getCurrentRequest();
$variantSettingsModifier = function (FormEvent $event, $isVariant) {
if ($isVariant) {
$event->getForm()->add(
Expand Down Expand Up @@ -427,7 +418,6 @@ function (FormEvent $event) use ($variantSettingsModifier) {
}
);

//add category
$builder->add(
'category',
CategoryListType::class,
Expand All @@ -436,7 +426,6 @@ function (FormEvent $event) use ($variantSettingsModifier) {
]
);

//add lead lists
$transformer = new IdToEntityModelTransformer($this->em, 'MauticLeadBundle:LeadList', 'id', true);
$builder->add(
$builder->create(
Expand Down Expand Up @@ -470,7 +459,6 @@ function (FormEvent $event) use ($variantSettingsModifier) {
]
);

//add lead lists
$transformer = new IdToEntityModelTransformer(
$this->em,
'MauticAssetBundle:Asset',
Expand All @@ -497,24 +485,21 @@ function (FormEvent $event) use ($variantSettingsModifier) {

$builder->add('sessionId', HiddenType::class);
$builder->add('emailType', HiddenType::class);

$customButtons = [
[
'name' => 'builder',
'label' => 'mautic.core.builder',
'attr' => [
'class' => 'btn btn-default btn-dnd btn-nospin text-primary btn-builder',
'icon' => 'fa fa-cube',
'onclick' => "Mautic.launchBuilder('email', 'email');",
],
],
];

$builder->add(
'buttons',
FormButtonsType::class,
[
'pre_extra_buttons' => $customButtons,
'pre_extra_buttons' => [
[
'name' => 'builder',
'label' => 'mautic.core.builder',
'attr' => [
'class' => 'btn btn-default btn-dnd btn-nospin text-primary btn-builder',
'icon' => 'fa fa-cube',
'onclick' => "Mautic.launchBuilder('{$this->getBlockPrefix()}', 'email');",
],
],
],
]
);

Expand Down Expand Up @@ -547,9 +532,6 @@ public function configureOptions(OptionsResolver $resolver)
$resolver->setDefined(['update_select']);
}

/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$stages = $this->stageModel->getRepository()->getSimpleList();
Expand All @@ -566,9 +548,6 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['stages'] = $stageChoices;
}

/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'emailform';
Expand Down

0 comments on commit bf569a1

Please sign in to comment.