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

FacebookLikeButtonBlockService::buildEditForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 39
rs 8.8571
cc 1
eloc 28
nc 1
nop 2
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 like button integration.
21
 *
22
 * @see https://developers.facebook.com/docs/plugins/like-button/
23
 *
24
 * @author Sylvain Deloux <[email protected]>
25
 */
26
class FacebookLikeButtonBlockService extends BaseFacebookSocialPluginsBlockService
27
{
28
    /**
29
     * @var string[]
30
     */
31
    protected $layoutList = array(
32
        'standard' => 'form.label_layout_standard',
33
        'box_count' => 'form.label_layout_box_count',
34
        'button_count' => 'form.label_layout_button_count',
35
        'button' => 'form.label_layout_button',
36
    );
37
38
    /**
39
     * @var string[]
40
     */
41
    protected $actionTypes = array(
42
        'like' => 'form.label_action_like',
43
        'recommend' => 'form.label_action_recommend',
44
    );
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function configureSettings(OptionsResolver $resolver)
50
    {
51
        $resolver->setDefaults(array(
52
            'template' => 'SonataSeoBundle:Block:block_facebook_like_button.html.twig',
53
            'url' => null,
54
            'width' => null,
55
            'show_faces' => true,
56
            'share' => true,
57
            'layout' => $this->layoutList['standard'],
58
            'colorscheme' => $this->colorschemeList['light'],
59
            'action' => $this->actionTypes['like'],
60
        ));
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
67
    {
68
        $formMapper->add('settings', 'sonata_type_immutable_array', array(
69
            'keys' => array(
70
                array('url', 'url', array(
71
                    'required' => false,
72
                    'label' => 'form.label_url',
73
                )),
74
                array('width', 'integer', array(
75
                    'required' => false,
76
                    'label' => 'form.label_width',
77
                )),
78
                array('show_faces', 'checkbox', array(
79
                    'required' => false,
80
                    'label' => 'form.label_show_faces',
81
                )),
82
                array('share', 'checkbox', array(
83
                    'required' => false,
84
                    'label' => 'form.label_share',
85
                )),
86
                array('layout', 'choice', array(
87
                    'required' => true,
88
                    'choices' => $this->layoutList,
89
                    'label' => 'form.label_layout',
90
                )),
91
                array('colorscheme', 'choice', array(
92
                    'required' => true,
93
                    'choices' => $this->colorschemeList,
94
                    'label' => 'form.label_colorscheme',
95
                )),
96
                array('action', 'choice', array(
97
                    'required' => true,
98
                    'choices' => $this->actionTypes,
99
                    'label' => 'form.label_action',
100
                )),
101
            ),
102
            'translation_domain' => 'SonataSeoBundle',
103
        ));
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function getBlockMetadata($code = null)
110
    {
111
        return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataSeoBundle', array(
112
            'class' => 'fa fa-facebook-official',
113
        ));
114
    }
115
}
116