Completed
Push — 2.x-dev-kit ( 971030 )
by
unknown
07:52
created

FacebookLikeBoxBlockService::buildEditForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 41
rs 8.8571
cc 1
eloc 29
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 box integration.
21
 *
22
 * @see https://developers.facebook.com/docs/plugins/like-box-for-pages/
23
 *
24
 * @author Sylvain Deloux <[email protected]>
25
 */
26
class FacebookLikeBoxBlockService extends BaseFacebookSocialPluginsBlockService
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function configureSettings(OptionsResolver $resolver)
32
    {
33
        $resolver->setDefaults(array(
34
            'template' => 'SonataSeoBundle:Block:block_facebook_like_box.html.twig',
35
            'url' => null,
36
            'width' => null,
37
            'height' => null,
38
            'colorscheme' => $this->colorschemeList['light'],
39
            'show_faces' => true,
40
            'show_header' => true,
41
            'show_posts' => false,
42
            'show_border' => true,
43
        ));
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
50
    {
51
        $formMapper->add('settings', 'sonata_type_immutable_array', array(
52
            'keys' => array(
53
                array('url', 'url', array(
54
                    'required' => false,
55
                    'label' => 'form.label_url',
56
                )),
57
                array('width', 'integer', array(
58
                    'required' => false,
59
                    'label' => 'form.label_width',
60
                )),
61
                array('height', 'integer', array(
62
                    'required' => false,
63
                    'label' => 'form.label_height',
64
                )),
65
                array('colorscheme', 'choice', array(
66
                    'required' => true,
67
                    'choices' => $this->colorschemeList,
68
                    'label' => 'form.label_colorscheme',
69
                )),
70
                array('show_faces', 'checkbox', array(
71
                    'required' => false,
72
                    'label' => 'form.label_show_faces',
73
                )),
74
                array('show_header', 'checkbox', array(
75
                    'required' => false,
76
                    'label' => 'form.label_show_header',
77
                )),
78
                array('show_posts', 'checkbox', array(
79
                    'required' => false,
80
                    'label' => 'form.label_show_posts',
81
                )),
82
                array('show_border', 'checkbox', array(
83
                    'required' => false,
84
                    'label' => 'form.label_show_border',
85
                )),
86
            ),
87
            'translation_domain' => 'SonataSeoBundle',
88
        ));
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function getBlockMetadata($code = null)
95
    {
96
        return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataSeoBundle', array(
97
            'class' => 'fa fa-facebook-official',
98
        ));
99
    }
100
}
101