|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PlaygroundGame\Controller\Frontend; |
|
4
|
|
|
|
|
5
|
|
|
use Zend\View\Model\ViewModel; |
|
6
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
7
|
|
|
|
|
8
|
|
|
class PrizeCategoryController extends GameController |
|
9
|
|
|
{ |
|
10
|
|
|
protected $gameService; |
|
11
|
|
|
|
|
12
|
|
|
protected $prizeCategoryService; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* |
|
16
|
|
|
* @var ServiceManager |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $serviceLocator; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct(ServiceLocatorInterface $locator) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->serviceLocator = $locator; |
|
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function getServiceLocator() |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
return $this->serviceLocator; |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function indexAction() |
|
32
|
|
|
{ |
|
33
|
|
|
$identifier = $this->getEvent()->getRouteMatch()->getParam('id'); |
|
34
|
|
|
|
|
35
|
|
|
if (!$identifier) { |
|
36
|
|
|
return $this->notFoundAction(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$prizeCategory = $this->getPrizeCategoryService()->getPrizeCategoryMapper()->findByIdentifier($identifier); |
|
40
|
|
|
$idPrizeCategory = $prizeCategory->getId(); |
|
41
|
|
|
|
|
42
|
|
|
$games = $this->getGameService()->getPrizeCategoryGames($idPrizeCategory); |
|
43
|
|
|
|
|
44
|
|
|
if (!$games) { |
|
45
|
|
|
$this->flashMessenger()->addMessage('Il n\'y a aucun jeu disponible pour cette thématique'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if (is_array($games)) { |
|
49
|
|
|
$paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\ArrayAdapter($games)); |
|
50
|
|
|
$paginator->setItemCountPerPage(7); |
|
51
|
|
|
$paginator->setCurrentPageNumber($this->getEvent()->getRouteMatch()->getParam('p')); |
|
52
|
|
|
} else { |
|
53
|
|
|
$paginator = $games; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$bitlyclient = $this->getOptions()->getBitlyUrl(); |
|
57
|
|
|
$bitlyuser = $this->getOptions()->getBitlyUsername(); |
|
58
|
|
|
$bitlykey = $this->getOptions()->getBitlyApiKey(); |
|
59
|
|
|
|
|
60
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('bt:client', $bitlyclient); |
|
61
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('bt:user', $bitlyuser); |
|
62
|
|
|
$this->getViewHelper('HeadMeta')->setProperty('bt:key', $bitlykey); |
|
63
|
|
|
|
|
64
|
|
|
$this->layout()->setVariables( |
|
|
|
|
|
|
65
|
|
|
array( |
|
66
|
|
|
'breadcrumbTitle' => $prizeCategory->getTitle(), |
|
67
|
|
|
'currentPage' => array( |
|
68
|
|
|
'pageGames' => 'games', |
|
69
|
|
|
'pageWinners' => '' |
|
70
|
|
|
), |
|
71
|
|
|
'headParams' => array( |
|
72
|
|
|
'headTitle' => $prizeCategory->getTitle(), |
|
73
|
|
|
), |
|
74
|
|
|
) |
|
75
|
|
|
); |
|
76
|
|
|
|
|
77
|
|
|
return new ViewModel( |
|
78
|
|
|
array( |
|
79
|
|
|
'games' => $paginator, |
|
80
|
|
|
'prizeCategory' => $prizeCategory, |
|
81
|
|
|
'identifier' => $identifier, |
|
82
|
|
|
'flashMessages' => $this->flashMessenger()->getMessages(), |
|
83
|
|
|
) |
|
84
|
|
|
); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getGameService() |
|
88
|
|
|
{ |
|
89
|
|
|
if (!$this->gameService) { |
|
90
|
|
|
$this->gameService = $this->getServiceLocator()->get('playgroundgame_game_service'); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
return $this->gameService; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getPrizeCategoryService() |
|
97
|
|
|
{ |
|
98
|
|
|
if (!$this->prizeCategoryService) { |
|
99
|
|
|
$this->prizeCategoryService = $this->getServiceLocator()->get('playgroundgame_prizecategory_service'); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
return $this->prizeCategoryService; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function setPrizeCategoryService(\PlaygroundGame\Service\PrizeCategory $prizeCategoryService) |
|
106
|
|
|
{ |
|
107
|
|
|
$this->prizeCategoryService = $prizeCategoryService; |
|
108
|
|
|
|
|
109
|
|
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..