|
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\Form\Extension\Core\Type\UrlType; |
|
27
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Twitter hashtag button integration. |
|
31
|
|
|
* |
|
32
|
|
|
* @see https://about.twitter.com/resources/buttons#hashtag |
|
33
|
|
|
* |
|
34
|
|
|
* @author Sylvain Deloux <[email protected]> |
|
35
|
|
|
*/ |
|
36
|
|
|
final class TwitterHashtagButtonBlockService extends BaseTwitterButtonBlockService implements EditableBlockService |
|
37
|
|
|
{ |
|
38
|
|
|
public function configureSettings(OptionsResolver $resolver): void |
|
39
|
|
|
{ |
|
40
|
|
|
$resolver->setDefaults([ |
|
41
|
|
|
'template' => '@SonataSeo/Block/block_twitter_hashtag_button.html.twig', |
|
42
|
|
|
'url' => null, |
|
43
|
|
|
'hashtag' => null, |
|
44
|
|
|
'text' => null, |
|
45
|
|
|
'recommend' => null, |
|
46
|
|
|
'large_button' => false, |
|
47
|
|
|
'opt_out' => false, |
|
48
|
|
|
'language' => $this->languageList['en'], |
|
49
|
|
|
]); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function configureCreateForm(FormMapper $formMapper, BlockInterface $block): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->configureEditForm($formMapper, $block); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function configureEditForm(FormMapper $formMapper, BlockInterface $block): void |
|
58
|
|
|
{ |
|
59
|
|
|
$formMapper->add('settings', ImmutableArrayType::class, [ |
|
60
|
|
|
'keys' => [ |
|
61
|
|
|
['hashtag', TextType::class, [ |
|
62
|
|
|
'required' => true, |
|
63
|
|
|
'label' => 'form.label_hashtag', |
|
64
|
|
|
]], |
|
65
|
|
|
['text', TextType::class, [ |
|
66
|
|
|
'required' => false, |
|
67
|
|
|
'label' => 'form.label_text', |
|
68
|
|
|
]], |
|
69
|
|
|
['recommend', TextType::class, [ |
|
70
|
|
|
'required' => false, |
|
71
|
|
|
'label' => 'form.label_recommend', |
|
72
|
|
|
]], |
|
73
|
|
|
['url', UrlType::class, [ |
|
74
|
|
|
'required' => false, |
|
75
|
|
|
'label' => 'form.label_url', |
|
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
|
|
|
public function getMetadata(): MetadataInterface |
|
100
|
|
|
{ |
|
101
|
|
|
return new Metadata('sonata.seo.block.twitter.hashtag_button', null, null, 'SonataSeoBundle', [ |
|
102
|
|
|
'class' => 'fa fa-twitter', |
|
103
|
|
|
]); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|