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

TwitterMentionButtonBlockService::buildEditForm()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 33
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 33
rs 8.8571
cc 1
eloc 23
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
 * Twitter mention button integration.
21
 *
22
 * @see https://about.twitter.com/resources/buttons#mention
23
 *
24
 * @author Sylvain Deloux <[email protected]>
25
 */
26
class TwitterMentionButtonBlockService extends BaseTwitterButtonBlockService
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function configureSettings(OptionsResolver $resolver)
32
    {
33
        $resolver->setDefaults(array(
34
            'template' => 'SonataSeoBundle:Block:block_twitter_mention_button.html.twig',
35
            'user' => null,
36
            'text' => null,
37
            'recommend' => null,
38
            'large_button' => false,
39
            'opt_out' => false,
40
            'language' => $this->languageList['en'],
41
        ));
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
48
    {
49
        $formMapper->add('settings', 'sonata_type_immutable_array', array(
50
            'keys' => array(
51
                array('user', 'text', array(
52
                    'required' => true,
53
                    'label' => 'form.label_user',
54
                )),
55
                array('text', 'text', array(
56
                    'required' => false,
57
                    'label' => 'form.label_text',
58
                )),
59
                array('recommend', 'text', array(
60
                    'required' => false,
61
                    'label' => 'form.label_recommend',
62
                )),
63
                array('large_button', 'checkbox', array(
64
                    'required' => false,
65
                    'label' => 'form.label_large_button',
66
                )),
67
                array('opt_out', 'checkbox', array(
68
                    'required' => false,
69
                    'label' => 'form.label_opt_out',
70
                )),
71
                array('language', 'choice', array(
72
                    'required' => true,
73
                    'choices' => $this->languageList,
74
                    'label' => 'form.label_language',
75
                )),
76
            ),
77
            'translation_domain' => 'SonataSeoBundle',
78
        ));
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function getBlockMetadata($code = null)
85
    {
86
        return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataSeoBundle', array(
87
            'class' => 'fa fa-twitter',
88
        ));
89
    }
90
}
91