Completed
Push — master ( 389b32...637f4d )
by Grégoire
13s queued 10s
created

Block/Social/TwitterMentionButtonBlockService.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\SeoBundle\Block\Social;
15
16
use Sonata\AdminBundle\Form\FormMapper;
17
use Sonata\BlockBundle\Model\BlockInterface;
18
use Sonata\CoreBundle\Form\Type\ImmutableArrayType;
19
use Sonata\CoreBundle\Model\Metadata;
20
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
21
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
22
use Symfony\Component\Form\Extension\Core\Type\TextType;
23
use Symfony\Component\OptionsResolver\OptionsResolver;
24
25
/**
26
 * Twitter mention button integration.
27
 *
28
 * @see https://about.twitter.com/resources/buttons#mention
29
 *
30
 * @author Sylvain Deloux <[email protected]>
31
 */
32
final class TwitterMentionButtonBlockService extends BaseTwitterButtonBlockService
33
{
34
    public function configureSettings(OptionsResolver $resolver): void
35
    {
36
        $resolver->setDefaults([
37
            'template' => '@SonataSeo/Block/block_twitter_mention_button.html.twig',
38
            'user' => null,
39
            'text' => null,
40
            'recommend' => null,
41
            'large_button' => false,
42
            'opt_out' => false,
43
            'language' => $this->languageList['en'],
44
        ]);
45
    }
46
47
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void
48
    {
49
        $formMapper->add('settings', ImmutableArrayType::class, [
50
            'keys' => [
51
                ['user', TextType::class, [
52
                    'required' => true,
53
                    'label' => 'form.label_user',
54
                ]],
55
                ['text', TextType::class, [
56
                    'required' => false,
57
                    'label' => 'form.label_text',
58
                ]],
59
                ['recommend', TextType::class, [
60
                    'required' => false,
61
                    'label' => 'form.label_recommend',
62
                ]],
63
                ['large_button', CheckboxType::class, [
64
                    'required' => false,
65
                    'label' => 'form.label_large_button',
66
                ]],
67
                ['opt_out', CheckboxType::class, [
68
                    'required' => false,
69
                    'label' => 'form.label_opt_out',
70
                ]],
71
                ['language', ChoiceType::class, [
72
                    'required' => true,
73
                    'choices' => $this->languageList,
74
                    'label' => 'form.label_language',
75
                ]],
76
            ],
77
            'translation_domain' => 'SonataSeoBundle',
78
        ]);
79
    }
80
81
    public function getBlockMetadata($code = null)
82
    {
83
        return new Metadata($this->getName(), (null !== $code ? $code : $this->getName()), false, 'SonataSeoBundle', [
0 ignored issues
show
Deprecated Code introduced by
The class Sonata\CoreBundle\Model\Metadata has been deprecated with message: since sonata-project/core-bundle 3.13.0, to be removed in 4.0. Use Sonata\BlockBundle\Meta\Metadata instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
84
            'class' => 'fa fa-twitter',
85
        ]);
86
    }
87
}
88