1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Zend Framework (http://framework.zend.com/) |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) |
7
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace PlaygroundCore\Controller\Admin; |
11
|
|
|
|
12
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
13
|
|
|
use Zend\View\Model\ViewModel; |
14
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
15
|
|
|
|
16
|
|
|
class WebsiteController extends AbstractActionController |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
protected $websiteService; |
20
|
|
|
|
21
|
|
|
protected $localeService; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* |
25
|
|
|
* @var ServiceManager |
26
|
|
|
*/ |
27
|
|
|
protected $serviceLocator; |
28
|
|
|
|
29
|
|
|
public function __construct(ServiceLocatorInterface $locator) |
30
|
|
|
{ |
31
|
|
|
$this->serviceLocator = $locator; |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getServiceLocator() |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
return $this->serviceLocator; |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function indexAction() |
41
|
|
|
{ |
42
|
|
|
return new ViewModel(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function listAction() |
46
|
|
|
{ |
47
|
|
|
$locales = $this->getLocaleService()->getLocaleMapper()->findBy(array('active_front' => 1)); |
48
|
|
|
$user = $this->zfcUserAuthentication()->getIdentity(); |
|
|
|
|
49
|
|
|
|
50
|
|
|
$websites = $this->getWebsiteService()->getWebsiteMapper()->findAll(); |
51
|
|
|
|
52
|
|
|
return new ViewModel(compact("websites", "locales", "user")); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function editActiveAction() |
56
|
|
|
{ |
57
|
|
|
$websiteId = $this->getEvent()->getRouteMatch()->getParam('websiteId'); |
58
|
|
|
$website = $this->getWebsiteService()->getWebsiteMapper()->findBy(array('id' => $websiteId)); |
59
|
|
|
$website = $website[0]; |
60
|
|
|
|
61
|
|
|
if ($website->getDefault()) { |
62
|
|
|
return $this->redirect()->toRoute('admin'); |
63
|
|
|
} |
64
|
|
|
$website->setActive(!$website->getActive()); |
65
|
|
|
$this->getWebsiteService()->getWebsiteMapper()->update($website); |
66
|
|
|
|
67
|
|
|
return $this->redirect()->toRoute('admin'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
View Code Duplication |
public function getWebsiteService() |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
if (null === $this->websiteService) { |
73
|
|
|
$this->websiteService = $this->getServiceLocator()->get('playgroundcore_website_service'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return $this->websiteService; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function setWebsiteService($websiteService) |
80
|
|
|
{ |
81
|
|
|
$this->websiteService = $websiteService; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
View Code Duplication |
public function getLocaleService() |
|
|
|
|
87
|
|
|
{ |
88
|
|
|
if (null === $this->localeService) { |
89
|
|
|
$this->localeService = $this->getServiceLocator()->get('playgroundcore_locale_service'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return $this->localeService; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function setLocaleService($localeService) |
96
|
|
|
{ |
97
|
|
|
$this->localeService = $localeService; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
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..