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\BlockBundle\Block\Service\EditableBlockService; |
17
|
|
|
use Sonata\BlockBundle\Form\Mapper\FormMapper; |
18
|
|
|
use Sonata\BlockBundle\Meta\Metadata; |
19
|
|
|
use Sonata\BlockBundle\Meta\MetadataInterface; |
20
|
|
|
use Sonata\BlockBundle\Model\BlockInterface; |
21
|
|
|
use Sonata\Form\Type\ImmutableArrayType; |
22
|
|
|
use Sonata\Form\Validator\ErrorElement; |
23
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
24
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
25
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
26
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Twitter mention button integration. |
30
|
|
|
* |
31
|
|
|
* @see https://about.twitter.com/resources/buttons#mention |
32
|
|
|
* |
33
|
|
|
* @author Sylvain Deloux <[email protected]> |
34
|
|
|
*/ |
35
|
|
|
class TwitterMentionButtonBlockService extends BaseTwitterButtonBlockService implements EditableBlockService |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function configureSettings(OptionsResolver $resolver): void |
41
|
|
|
{ |
42
|
|
|
$resolver->setDefaults([ |
43
|
|
|
'template' => '@SonataSeo/Block/block_twitter_mention_button.html.twig', |
44
|
|
|
'user' => null, |
45
|
|
|
'text' => null, |
46
|
|
|
'recommend' => null, |
47
|
|
|
'large_button' => false, |
48
|
|
|
'opt_out' => false, |
49
|
|
|
'language' => $this->languageList['en'], |
50
|
|
|
]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function configureCreateForm(FormMapper $form, BlockInterface $block): void |
54
|
|
|
{ |
55
|
|
|
$this->configureEditForm($form, $block); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
|
|
public function configureEditForm(FormMapper $form, BlockInterface $block): void |
62
|
|
|
{ |
63
|
|
|
$form->add('settings', ImmutableArrayType::class, [ |
64
|
|
|
'keys' => [ |
65
|
|
|
['user', TextType::class, [ |
66
|
|
|
'required' => true, |
67
|
|
|
'label' => 'form.label_user', |
68
|
|
|
]], |
69
|
|
|
['text', TextType::class, [ |
70
|
|
|
'required' => false, |
71
|
|
|
'label' => 'form.label_text', |
72
|
|
|
]], |
73
|
|
|
['recommend', TextType::class, [ |
74
|
|
|
'required' => false, |
75
|
|
|
'label' => 'form.label_recommend', |
76
|
|
|
]], |
77
|
|
|
['large_button', CheckboxType::class, [ |
78
|
|
|
'required' => false, |
79
|
|
|
'label' => 'form.label_large_button', |
80
|
|
|
]], |
81
|
|
|
['opt_out', CheckboxType::class, [ |
82
|
|
|
'required' => false, |
83
|
|
|
'label' => 'form.label_opt_out', |
84
|
|
|
]], |
85
|
|
|
['language', ChoiceType::class, [ |
86
|
|
|
'required' => true, |
87
|
|
|
'choices' => $this->languageList, |
88
|
|
|
'label' => 'form.label_language', |
89
|
|
|
]], |
90
|
|
|
], |
91
|
|
|
'translation_domain' => 'SonataSeoBundle', |
92
|
|
|
]); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function validate(ErrorElement $errorElement, BlockInterface $block): void |
96
|
|
|
{ |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
public function getMetadata(): MetadataInterface |
103
|
|
|
{ |
104
|
|
|
return new Metadata('sonata.seo.block.twitter.mention_button', null, null, 'SonataSeoBundle', [ |
105
|
|
|
'class' => 'fa fa-twitter', |
106
|
|
|
]); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|