1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Bundle\DefaultBundle\Service\EventBlock; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Persistence\ObjectRepository; |
6
|
|
|
use Sonata\BlockBundle\Block\Service\AbstractBlockService; |
7
|
|
|
use Sonata\BlockBundle\Block\BlockContextInterface; |
8
|
|
|
use Stfalcon\Bundle\EventBundle\Entity\Event; |
9
|
|
|
use Stfalcon\Bundle\EventBundle\Repository\ReviewRepository; |
10
|
|
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
11
|
|
|
use Symfony\Component\HttpFoundation\Response; |
12
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
13
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
14
|
|
|
use Symfony\Component\Translation\IdentityTranslator; |
15
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class CommitteeSpeakersEventBlockService. |
19
|
|
|
*/ |
20
|
|
|
class CommitteeSpeakersEventBlockService extends AbstractBlockService |
21
|
|
|
{ |
22
|
|
|
/** @var IdentityTranslator */ |
23
|
|
|
private $translator; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* SpeakersEventBlockService constructor. |
27
|
|
|
* |
28
|
|
|
* @param string $name |
29
|
|
|
* @param EngineInterface $templating |
30
|
|
|
* @param TranslatorInterface $translator |
31
|
|
|
*/ |
32
|
|
|
public function __construct($name, EngineInterface $templating, TranslatorInterface $translator) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($name, $templating); |
35
|
|
|
|
36
|
|
|
$this->translator = $translator; |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function execute(BlockContextInterface $blockContext, Response $response = null) |
43
|
|
|
{ |
44
|
|
|
$event = $blockContext->getSetting('event'); |
45
|
|
|
|
46
|
|
|
if (!$event instanceof Event) { |
47
|
|
|
return new NotFoundHttpException(); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$speakers = $event->getCommitteeSpeakers(); |
51
|
|
|
|
52
|
|
|
return $this->renderResponse($blockContext->getTemplate(), [ |
53
|
|
|
'block' => $blockContext->getBlock(), |
54
|
|
|
'templateTitle' => $this->translator->trans('committee.speaker.title'), |
55
|
|
|
'speakers' => $speakers, |
56
|
|
|
'section_id' => 'committee-speakers-event', |
57
|
|
|
'with_review' => false, |
58
|
|
|
'event' => $event, |
59
|
|
|
], $response); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritdoc} |
64
|
|
|
*/ |
65
|
|
|
public function configureSettings(OptionsResolver $resolver) |
66
|
|
|
{ |
67
|
|
|
$resolver->setDefaults([ |
68
|
|
|
'template' => 'ApplicationDefaultBundle:Redesign/Event:event.speakers.html.twig', |
69
|
|
|
'event' => null, |
70
|
|
|
'event_block' => null, |
71
|
|
|
]); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.