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

FacebookSendButtonBlockService::buildEditForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

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