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