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\IntegerType; |
26
|
|
|
use Symfony\Component\Form\Extension\Core\Type\UrlType; |
27
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Facebook like box integration. |
31
|
|
|
* |
32
|
|
|
* @see https://developers.facebook.com/docs/plugins/like-box-for-pages/ |
33
|
|
|
* |
34
|
|
|
* @author Sylvain Deloux <[email protected]> |
35
|
|
|
*/ |
36
|
|
|
final class FacebookLikeBoxBlockService extends BaseFacebookSocialPluginsBlockService implements EditableBlockService |
37
|
|
|
{ |
38
|
|
|
public function configureSettings(OptionsResolver $resolver): void |
39
|
|
|
{ |
40
|
|
|
$resolver->setDefaults([ |
41
|
|
|
'template' => '@SonataSeo/Block/block_facebook_like_box.html.twig', |
42
|
|
|
'url' => null, |
43
|
|
|
'width' => null, |
44
|
|
|
'height' => null, |
45
|
|
|
'colorscheme' => $this->colorschemeList['light'], |
46
|
|
|
'show_faces' => true, |
47
|
|
|
'show_header' => true, |
48
|
|
|
'show_posts' => false, |
49
|
|
|
'show_border' => true, |
50
|
|
|
]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function configureCreateForm(FormMapper $formMapper, BlockInterface $block): void |
54
|
|
|
{ |
55
|
|
|
$this->configureEditForm($formMapper, $block); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function configureEditForm(FormMapper $formMapper, BlockInterface $block): void |
59
|
|
|
{ |
60
|
|
|
$formMapper->add('settings', ImmutableArrayType::class, [ |
61
|
|
|
'keys' => [ |
62
|
|
|
['url', UrlType::class, [ |
63
|
|
|
'required' => false, |
64
|
|
|
'label' => 'form.label_url', |
65
|
|
|
]], |
66
|
|
|
['width', IntegerType::class, [ |
67
|
|
|
'required' => false, |
68
|
|
|
'label' => 'form.label_width', |
69
|
|
|
]], |
70
|
|
|
['height', IntegerType::class, [ |
71
|
|
|
'required' => false, |
72
|
|
|
'label' => 'form.label_height', |
73
|
|
|
]], |
74
|
|
|
['colorscheme', ChoiceType::class, [ |
75
|
|
|
'required' => true, |
76
|
|
|
'choices' => $this->colorschemeList, |
77
|
|
|
'label' => 'form.label_colorscheme', |
78
|
|
|
]], |
79
|
|
|
['show_faces', CheckboxType::class, [ |
80
|
|
|
'required' => false, |
81
|
|
|
'label' => 'form.label_show_faces', |
82
|
|
|
]], |
83
|
|
|
['show_header', CheckboxType::class, [ |
84
|
|
|
'required' => false, |
85
|
|
|
'label' => 'form.label_show_header', |
86
|
|
|
]], |
87
|
|
|
['show_posts', CheckboxType::class, [ |
88
|
|
|
'required' => false, |
89
|
|
|
'label' => 'form.label_show_posts', |
90
|
|
|
]], |
91
|
|
|
['show_border', CheckboxType::class, [ |
92
|
|
|
'required' => false, |
93
|
|
|
'label' => 'form.label_show_border', |
94
|
|
|
]], |
95
|
|
|
], |
96
|
|
|
'translation_domain' => 'SonataSeoBundle', |
97
|
|
|
]); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function validate(ErrorElement $errorElement, BlockInterface $block): void |
101
|
|
|
{ |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getMetadata(): MetadataInterface |
105
|
|
|
{ |
106
|
|
|
return new Metadata('sonata.seo.block.facebook.like_box', null, null, 'SonataSeoBundle', [ |
107
|
|
|
'class' => 'fa fa-facebook-official', |
108
|
|
|
]); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|