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
|
|
|
* This block offers a button to share current page by email. |
24
|
|
|
* |
25
|
|
|
* @author Vincent Composieux <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class EmailShareButtonBlockService extends BaseBlockService |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function configureSettings(OptionsResolver $resolver) |
33
|
|
|
{ |
34
|
|
|
$resolver->setDefaults(array( |
35
|
|
|
'template' => 'SonataSeoBundle:Block:block_email_share_button.html.twig', |
36
|
|
|
'subject' => null, |
37
|
|
|
'body' => null, |
38
|
|
|
)); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function buildEditForm(FormMapper $formMapper, BlockInterface $block) |
45
|
|
|
{ |
46
|
|
|
$formMapper->add('settings', 'sonata_type_immutable_array', array( |
47
|
|
|
'keys' => array( |
48
|
|
|
array('subject', 'text', array( |
49
|
|
|
'required' => false, |
50
|
|
|
'label' => 'form.label_subject', |
51
|
|
|
)), |
52
|
|
|
array('body', 'text', array( |
53
|
|
|
'required' => false, |
54
|
|
|
'label' => 'form.label_body', |
55
|
|
|
)), |
56
|
|
|
), |
57
|
|
|
'translation_domain' => 'SonataSeoBundle', |
58
|
|
|
)); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
*/ |
64
|
|
|
public function execute(BlockContextInterface $blockContext, Response $response = null) |
65
|
|
|
{ |
66
|
|
|
$block = $blockContext->getBlock(); |
67
|
|
|
$settings = array_merge($blockContext->getSettings(), $block->getSettings()); |
68
|
|
|
|
69
|
|
|
return $this->renderResponse($blockContext->getTemplate(), array( |
70
|
|
|
'block' => $blockContext->getBlock(), |
71
|
|
|
'settings' => $settings, |
72
|
|
|
), $response); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function getBlockMetadata($code = null) |
79
|
|
|
{ |
80
|
|
|
return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataSeoBundle', array( |
81
|
|
|
'class' => 'fa fa-envelope-o', |
82
|
|
|
)); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|