|
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\Block\BaseBlockService; |
|
16
|
|
|
use Sonata\BlockBundle\Block\BlockContextInterface; |
|
17
|
|
|
use Sonata\BlockBundle\Model\BlockInterface; |
|
18
|
|
|
use Sonata\CoreBundle\Model\Metadata; |
|
19
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
20
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Pinterest pin button integration. |
|
24
|
|
|
* |
|
25
|
|
|
* @see http://fr.business.pinterest.com/widget-builder/#do_pin_it_button |
|
26
|
|
|
* |
|
27
|
|
|
* @author Vincent Composieux <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class PinterestPinButtonBlockService extends BaseBlockService |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function configureSettings(OptionsResolver $resolver) |
|
35
|
|
|
{ |
|
36
|
|
|
$resolver->setDefaults(array( |
|
37
|
|
|
'template' => 'SonataSeoBundle:Block:block_pinterest_pin_button.html.twig', |
|
38
|
|
|
'size' => null, |
|
39
|
|
|
'shape' => null, |
|
40
|
|
|
'url' => null, |
|
41
|
|
|
'image' => null, |
|
42
|
|
|
'description' => null, |
|
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('image', 'text', array( |
|
58
|
|
|
'required' => false, |
|
59
|
|
|
'label' => 'form.label_image', |
|
60
|
|
|
)), |
|
61
|
|
|
array('description', 'text', array( |
|
62
|
|
|
'required' => false, |
|
63
|
|
|
'label' => 'form.label_description', |
|
64
|
|
|
)), |
|
65
|
|
|
array('size', 'integer', array( |
|
66
|
|
|
'required' => false, |
|
67
|
|
|
'label' => 'form.label_size', |
|
68
|
|
|
)), |
|
69
|
|
|
array('shape', 'choice', array( |
|
70
|
|
|
'required' => false, |
|
71
|
|
|
'choices' => array( |
|
72
|
|
|
'rectangular' => 'form.label_shape_rectangular', |
|
73
|
|
|
'round' => 'form.label_shape_round', |
|
74
|
|
|
), |
|
75
|
|
|
'label' => 'form.label_shape', |
|
76
|
|
|
)), |
|
77
|
|
|
), |
|
78
|
|
|
'translation_domain' => 'SonataSeoBundle', |
|
79
|
|
|
)); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritdoc} |
|
84
|
|
|
*/ |
|
85
|
|
|
public function execute(BlockContextInterface $blockContext, Response $response = null) |
|
86
|
|
|
{ |
|
87
|
|
|
$block = $blockContext->getBlock(); |
|
88
|
|
|
$settings = array_merge($blockContext->getSettings(), $block->getSettings()); |
|
89
|
|
|
|
|
90
|
|
|
return $this->renderResponse($blockContext->getTemplate(), array( |
|
91
|
|
|
'block' => $blockContext->getBlock(), |
|
92
|
|
|
'settings' => $settings, |
|
93
|
|
|
), $response); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* {@inheritdoc} |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getBlockMetadata($code = null) |
|
100
|
|
|
{ |
|
101
|
|
|
return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataSeoBundle', array( |
|
102
|
|
|
'class' => 'fa fa-pinterest-p', |
|
103
|
|
|
)); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|