Completed
Push — 2.x-dev-kit ( cbb19e )
by
unknown
05:26 queued 02:48
created

FacebookShareButtonBlockService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 4
c 5
b 1
f 0
lcom 1
cbo 4
dl 0
loc 62
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBlockMetadata() 0 6 2
A configureSettings() 0 9 1
A buildEditForm() 0 21 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\SeoBundle\Block\Social;
13
14
use Sonata\AdminBundle\Form\FormMapper;
15
use Sonata\BlockBundle\Model\BlockInterface;
16
use Sonata\CoreBundle\Model\Metadata;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
19
/**
20
 * Facebook share button integration.
21
 *
22
 * @see https://developers.facebook.com/docs/plugins/share-button/
23
 *
24
 * @author Sylvain Deloux <[email protected]>
25
 */
26
class FacebookShareButtonBlockService extends BaseFacebookSocialPluginsBlockService
27
{
28
    /**
29
     * @var string[]
30
     */
31
    protected $layoutList = array(
32
        'box_count' => 'form.label_layout_box_count',
33
        'button_count' => 'form.label_layout_button_count',
34
        'button' => 'form.label_layout_button',
35
        'icon_link' => 'form.label_layout_icon_link',
36
        'icon' => 'form.label_layout_icon',
37
        'link' => 'form.label_layout_link',
38
    );
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function configureSettings(OptionsResolver $resolver)
44
    {
45
        $resolver->setDefaults(array(
46
            'template' => 'SonataSeoBundle:Block:block_facebook_share_button.html.twig',
47
            'url' => null,
48
            'width' => null,
49
            'layout' => $this->layoutList['box_count'],
50
        ));
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
57
    {
58
        $formMapper->add('settings', 'sonata_type_immutable_array', array(
59
            'keys' => array(
60
                array('url', 'url', array(
61
                    'required' => false,
62
                    'label' => 'form.label_url',
63
                )),
64
                array('width', 'integer', array(
65
                    'required' => false,
66
                    'label' => 'form.label_width',
67
                )),
68
                array('layout', 'choice', array(
69
                    'required' => true,
70
                    'choices' => $this->layoutList,
71
                    'label' => 'form.label_layout',
72
                )),
73
            ),
74
            'translation_domain' => 'SonataSeoBundle',
75
        ));
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function getBlockMetadata($code = null)
82
    {
83
        return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataSeoBundle', array(
84
            'class' => 'fa fa-facebook-official',
85
        ));
86
    }
87
}
88