Conditions | 12 |
Paths | 3 |
Total Lines | 62 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
31 | protected function configureFormFields(FormMapper $formMapper) |
||
32 | { |
||
33 | $media = $this->getSubject(); |
||
34 | |||
35 | $formMapper->with('Media', ['class' => 'col-md-6']) |
||
36 | |||
37 | ->add('mediaFile', FileType::class, [ |
||
38 | 'label' => 'admin.media.mediaFile.label', |
||
39 | 'required' => $this->getSubject() && $this->getSubject()->getMedia() ? false : true, |
||
40 | ]) |
||
41 | ->add('name', TextType::class, [ |
||
42 | 'required' => $this->getSubject() && $this->getSubject()->getMedia() ? true : false, |
||
43 | 'help_html' => true, |
||
44 | 'help' => 'admin.media.name.help', |
||
45 | 'label' => 'admin.media.name.label', |
||
46 | 'attr' => ['ismedia' => 1, 'class' => 'col-md-6'], |
||
47 | ]) |
||
48 | ->add('slugForce', TextType::class, [ |
||
49 | 'label' => 'admin.page.slug.label', |
||
50 | 'help_html' => true, |
||
51 | 'required' => false, |
||
52 | 'help' => $this->getSubject() && $this->getSubject()->getSlug() |
||
53 | ? '<span class="btn btn-link" onclick="toggleDisabled()" id="disabledLinkSlug"> |
||
54 | <i class="fa fa-unlock"></i></span> |
||
55 | <script>function toggleDisabled() { |
||
56 | $(".slug_disabled").first().removeAttr("disabled"); |
||
57 | $(".slug_disabled").first().focus(); |
||
58 | $("#disabledLinkSlug").first().remove(); |
||
59 | }</script>' |
||
60 | .'<small>Changer le slug change l\'URL de l\'image et peut créer des erreurs.</small>' |
||
61 | : 'admin.page.slug.help', |
||
62 | 'attr' => [ |
||
63 | 'class' => 'slug_disabled', |
||
64 | ($this->getSubject() ? ($this->getSubject()->getSlug() ? 'disabled' : 't') : 't') => '', |
||
65 | ], |
||
66 | ]) |
||
67 | ->end(); |
||
68 | |||
69 | $formMapper->with('i18n', ['class' => 'col-md-6']); |
||
70 | |||
71 | $formMapper->add('names', null, [ |
||
72 | 'required' => false, |
||
73 | 'help_html' => true, 'help' => 'admin.media.names.help', |
||
74 | 'label' => 'admin.media.names.label', |
||
75 | 'attr' => ['ismedia' => 1, 'class' => 'col-md-6'], |
||
76 | ]); |
||
77 | |||
78 | $formMapper->end(); |
||
79 | |||
80 | if ($media && $media->getMedia()) { |
||
81 | $formMapper->with('admin.media.preview.label', [ |
||
82 | 'class' => 'col-md-12', |
||
83 | 'description' => $this->showMediaPreview(), |
||
84 | //'empty_message' => false, // to uncomment when sonataAdmin 3.62 is released |
||
85 | ])->end(); |
||
86 | |||
87 | if ($this->issetRelatedPages()) { |
||
88 | $formMapper->with('admin.media.related.label', [ |
||
89 | 'class' => 'col-md-12', |
||
90 | 'description' => $this->showRelatedPages(), |
||
91 | //'empty_message' => false, /// to uncomment when sonataAdmin 3.62 is released |
||
92 | ])->end(); |
||
93 | } |
||
200 |