Completed
Push — master ( 2cf16b...bf4a2d )
by Jordi Sala
13:35 queued 22s
created

configureEditForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 2
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\Form\Mapper\FormMapper;
17
use Sonata\BlockBundle\Meta\Metadata;
18
use Sonata\BlockBundle\Meta\MetadataInterface;
19
use Sonata\BlockBundle\Model\BlockInterface;
20
use Sonata\Form\Type\ImmutableArrayType;
21
use Sonata\Form\Validator\ErrorElement;
22
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
23
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
24
use Symfony\Component\Form\Extension\Core\Type\UrlType;
25
use Symfony\Component\OptionsResolver\OptionsResolver;
26
27
/**
28
 * Facebook share button integration.
29
 *
30
 * @see https://developers.facebook.com/docs/plugins/share-button/
31
 *
32
 * @author Sylvain Deloux <[email protected]>
33
 */
34
final class FacebookShareButtonBlockService extends BaseFacebookSocialPluginsBlockService
35
{
36
    /**
37
     * @var string[]
38
     */
39
    protected $layoutList = [
40
        'box_count' => 'form.label_layout_box_count',
41
        'button_count' => 'form.label_layout_button_count',
42
        'button' => 'form.label_layout_button',
43
        'icon_link' => 'form.label_layout_icon_link',
44
        'icon' => 'form.label_layout_icon',
45
        'link' => 'form.label_layout_link',
46
    ];
47
48
    public function configureSettings(OptionsResolver $resolver): void
49
    {
50
        $resolver->setDefaults([
51
            'template' => '@SonataSeo/Block/block_facebook_share_button.html.twig',
52
            'url' => null,
53
            'width' => null,
54
            'layout' => $this->layoutList['box_count'],
55
        ]);
56
    }
57
58
    public function configureCreateForm(FormMapper $formMapper, BlockInterface $block): void
59
    {
60
        $this->configureEditForm($formMapper, $block);
61
    }
62
63
    public function configureEditForm(FormMapper $formMapper, BlockInterface $block): void
0 ignored issues
show
Unused Code introduced by
The parameter $block is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65
        $formMapper->add('settings', ImmutableArrayType::class, [
66
            'keys' => [
67
                ['url', UrlType::class, [
68
                    'required' => false,
69
                    'label' => 'form.label_url',
70
                ]],
71
                ['width', IntegerType::class, [
72
                    'required' => false,
73
                    'label' => 'form.label_width',
74
                ]],
75
                ['layout', ChoiceType::class, [
76
                    'required' => true,
77
                    'choices' => $this->layoutList,
78
                    'label' => 'form.label_layout',
79
                ]],
80
            ],
81
            'translation_domain' => 'SonataSeoBundle',
82
        ]);
83
    }
84
85
    public function validate(ErrorElement $errorElement, BlockInterface $block): void
0 ignored issues
show
Unused Code introduced by
The parameter $errorElement is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $block is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
86
    {
87
    }
88
89
    public function getMetadata(): MetadataInterface
90
    {
91
        return new Metadata('sonata.seo.block.facebook.share_button', null, null, 'SonataSeoBundle', [
92
            'class' => 'fa fa-facebook-official',
93
        ]);
94
    }
95
}
96