1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2014 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\CoreBundle\Form\Type; |
||
13 | |||
14 | use Mautic\LeadBundle\Helper\FormFieldHelper; |
||
15 | use Mautic\LeadBundle\Model\ListModel; |
||
16 | use Mautic\StageBundle\Model\StageModel; |
||
17 | use Symfony\Component\Form\AbstractType; |
||
18 | use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
||
19 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
||
20 | use Symfony\Component\Form\FormBuilderInterface; |
||
21 | use Symfony\Component\Form\FormInterface; |
||
22 | use Symfony\Component\Form\FormView; |
||
23 | use Symfony\Component\OptionsResolver\OptionsResolver; |
||
24 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | class DynamicContentFilterEntryType extends AbstractType |
||
27 | { |
||
28 | private $fieldChoices = []; |
||
29 | private $countryChoices = []; |
||
30 | private $regionChoices = []; |
||
31 | private $timezoneChoices = []; |
||
32 | private $localeChoices = []; |
||
33 | |||
34 | /** |
||
35 | * @var StageModel |
||
36 | */ |
||
37 | private $stageModel; |
||
38 | |||
39 | public function __construct(ListModel $listModel, StageModel $stageModel) |
||
40 | { |
||
41 | $this->fieldChoices = $listModel->getChoiceFields(); |
||
42 | |||
43 | $this->filterFieldChoices(); |
||
44 | |||
45 | $this->countryChoices = FormFieldHelper::getCountryChoices(); |
||
46 | $this->regionChoices = FormFieldHelper::getRegionChoices(); |
||
47 | $this->timezoneChoices = FormFieldHelper::getTimezonesChoices(); |
||
48 | $this->localeChoices = FormFieldHelper::getLocaleChoices(); |
||
49 | $this->stageModel = $stageModel; |
||
50 | } |
||
51 | |||
52 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
53 | { |
||
54 | $builder->add( |
||
55 | 'content', |
||
56 | TextareaType::class, |
||
57 | [ |
||
58 | 'label' => 'mautic.core.dynamicContent.alt_content', |
||
59 | 'attr' => [ |
||
60 | 'class' => 'form-control editor editor-dynamic-content', |
||
61 | ], |
||
62 | ] |
||
63 | ); |
||
64 | |||
65 | $builder->add( |
||
66 | $builder->create( |
||
67 | 'filters', |
||
68 | CollectionType::class, |
||
69 | [ |
||
70 | 'entry_type' => DynamicContentFilterEntryFiltersType::class, |
||
71 | 'entry_options' => [ |
||
72 | 'label' => false, |
||
73 | 'attr' => [ |
||
74 | 'class' => 'form-control', |
||
75 | ], |
||
76 | 'countries' => $this->countryChoices, |
||
77 | 'regions' => $this->regionChoices, |
||
78 | 'timezones' => $this->timezoneChoices, |
||
79 | 'stages' => $this->getStageList(), |
||
80 | 'locales' => $this->localeChoices, |
||
81 | 'fields' => $this->fieldChoices, |
||
82 | ], |
||
83 | 'error_bubbling' => false, |
||
84 | 'mapped' => true, |
||
85 | 'allow_add' => true, |
||
86 | 'allow_delete' => true, |
||
87 | 'label' => false, |
||
88 | ] |
||
89 | ) |
||
90 | ); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function buildView(FormView $view, FormInterface $form, array $options) |
||
97 | { |
||
98 | $view->vars['fields'] = $this->fieldChoices; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * @param OptionsResolverInterface $resolver |
||
103 | */ |
||
104 | public function configureOptions(OptionsResolver $resolver) |
||
105 | { |
||
106 | $resolver->setDefaults( |
||
107 | [ |
||
108 | 'label' => false, |
||
109 | 'error_bubbling' => false, |
||
110 | ] |
||
111 | ); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @return string |
||
116 | */ |
||
117 | public function getBlockPrefix() |
||
118 | { |
||
119 | return 'dynamic_content_filter_entry'; |
||
120 | } |
||
121 | |||
122 | private function filterFieldChoices() |
||
123 | { |
||
124 | $this->fieldChoices['lead'] = array_filter( |
||
125 | $this->fieldChoices['lead'], |
||
126 | function ($key) { |
||
127 | return !in_array( |
||
128 | $key, |
||
129 | [ |
||
130 | 'company', |
||
131 | 'leadlist', |
||
132 | 'campaign', |
||
133 | 'device_type', |
||
134 | 'device_brand', |
||
135 | 'device_os', |
||
136 | 'lead_email_received', |
||
137 | 'tags', |
||
138 | 'dnc_bounced', |
||
139 | 'dnc_unsubscribed', |
||
140 | 'dnc_bounced_sms', |
||
141 | 'dnc_unsubscribed_sms', |
||
142 | 'hit_url', |
||
143 | ] |
||
144 | ); |
||
145 | }, |
||
146 | ARRAY_FILTER_USE_KEY |
||
147 | ); |
||
148 | } |
||
149 | |||
150 | private function getStageList(): array |
||
151 | { |
||
152 | $stages = $this->stageModel->getRepository()->getSimpleList(); |
||
153 | |||
154 | foreach ($stages as $stage) { |
||
155 | $stages[$stage['value']] = $stage['label']; |
||
156 | } |
||
157 | |||
158 | return $stages; |
||
159 | } |
||
160 | } |
||
161 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths