1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\VotingBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Kunstmaan\VotingBundle\Event\Events; |
6
|
|
|
use Kunstmaan\VotingBundle\Event\Facebook\FacebookLikeEvent; |
7
|
|
|
use Kunstmaan\VotingBundle\Event\Facebook\FacebookSendEvent; |
8
|
|
|
use Kunstmaan\VotingBundle\Event\LinkedIn\LinkedInShareEvent; |
9
|
|
|
use Kunstmaan\VotingBundle\Event\UpDown\DownVoteEvent; |
10
|
|
|
use Kunstmaan\VotingBundle\Event\UpDown\UpVoteEvent; |
11
|
|
|
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; |
12
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
13
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
|
17
|
|
|
class VotingController extends Controller |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @Route("/voting-upvote", name="voting_upvote") |
21
|
|
|
* @Template("@KunstmaanVoting/UpDown/voted.html.twig") |
22
|
|
|
* |
23
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
24
|
|
|
*/ |
25
|
|
|
public function upVoteAction(Request $request) |
26
|
|
|
{ |
27
|
|
|
$reference = $request->get('reference'); |
28
|
|
|
$value = $request->get('value'); |
29
|
|
|
$this->dispatch(new UpVoteEvent($request, $reference, $value), Events::VOTE_UP); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @Route("/voting-downvote", name="voting_downvote") |
34
|
|
|
* @Template("@KunstmaanVoting/UpDown/voted.html.twig") |
35
|
|
|
* |
36
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
37
|
|
|
*/ |
38
|
|
|
public function downVoteAction(Request $request) |
39
|
|
|
{ |
40
|
|
|
$reference = $request->get('reference'); |
41
|
|
|
$value = $request->get('value'); |
42
|
|
|
$this->dispatch(new DownVoteEvent($request, $reference, $value), Events::VOTE_DOWN); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @Route("/voting-facebooklike", name="voting_facebooklike") |
47
|
|
|
* |
48
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
49
|
|
|
*/ |
50
|
|
|
public function facebookLikeAction(Request $request) |
51
|
|
|
{ |
52
|
|
|
$response = $request->get('response'); |
53
|
|
|
$value = $request->get('value'); |
54
|
|
|
$this->dispatch(new FacebookLikeEvent($request, $response, $value), Events::FACEBOOK_LIKE); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Route("/voting-facebooksend", name="voting_facebooksend") |
59
|
|
|
* |
60
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
61
|
|
|
*/ |
62
|
|
|
public function facebookSendAction(Request $request) |
63
|
|
|
{ |
64
|
|
|
$response = $request->get('response'); |
65
|
|
|
$value = $request->get('value'); |
66
|
|
|
$this->dispatch(new FacebookSendEvent($request, $response, $value), Events::FACEBOOK_SEND); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Route("/voting-linkedinshare", name="voting_linkedinshare") |
71
|
|
|
* |
72
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
73
|
|
|
*/ |
74
|
|
|
public function linkedInShareAction(Request $request) |
75
|
|
|
{ |
76
|
|
|
$reference = $request->get('reference'); |
77
|
|
|
$value = $request->get('value'); |
78
|
|
|
$this->dispatch(new LinkedInShareEvent($request, $reference, $value), Events::LINKEDIN_SHARE); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param object $event |
83
|
|
|
* @param string $eventName |
84
|
|
|
* |
85
|
|
|
* @return object |
86
|
|
|
*/ |
87
|
|
View Code Duplication |
private function dispatch($event, string $eventName) |
88
|
|
|
{ |
89
|
|
|
$eventDispatcher = $this->container->get('event_dispatcher'); |
90
|
|
|
if (class_exists(LegacyEventDispatcherProxy::class)) { |
91
|
|
|
$eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher); |
92
|
|
|
|
93
|
|
|
return $eventDispatcher->dispatch($event, $eventName); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
return $eventDispatcher->dispatch($eventName, $event); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.