|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* YAWIK |
|
5
|
|
|
* |
|
6
|
|
|
* @filesource |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
* @copyright 2013 - 2017 Cross Solution <http://cross-solution.de> |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Organizations\Controller; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
use Auth\Exception\UnauthorizedAccessException; |
|
15
|
|
|
use Core\Entity\Exception\NotFoundException; |
|
16
|
|
|
use Jobs\Repository\Job as JobRepository; |
|
17
|
|
|
use Organizations\Entity\Organization; |
|
18
|
|
|
use Organizations\Repository\Organization as OrganizationRepository; |
|
19
|
|
|
use Zend\Http\Response; |
|
20
|
|
|
use Zend\I18n\Translator\TranslatorInterface; |
|
21
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
|
22
|
|
|
use Zend\View\Model\ViewModel; |
|
23
|
|
|
use Organizations\ImageFileCache\Manager as ImageFileCacheManager; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class ProfileController |
|
27
|
|
|
* |
|
28
|
|
|
* @author Anthonius Munthi <[email protected]> |
|
29
|
|
|
* @package Organizations\Controller |
|
30
|
|
|
* @since 0.30.1 |
|
31
|
|
|
*/ |
|
32
|
|
|
class ProfileController extends AbstractActionController |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var OrganizationRepository |
|
36
|
|
|
*/ |
|
37
|
|
|
private $repo; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var JobRepository |
|
41
|
|
|
*/ |
|
42
|
|
|
private $jobRepo; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var TranslatorInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
private $translator; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var ImageFileCacheManager |
|
51
|
|
|
*/ |
|
52
|
|
|
private $imageFileCacheManager; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var array |
|
56
|
|
|
*/ |
|
57
|
|
|
private $options = [ |
|
58
|
|
|
'count' => 10, |
|
59
|
|
|
]; |
|
60
|
|
|
|
|
61
|
|
|
public function __construct( |
|
62
|
|
|
OrganizationRepository $repo, |
|
63
|
|
|
JobRepository $jobRepository, |
|
64
|
|
|
TranslatorInterface $translator, |
|
65
|
|
|
ImageFileCacheManager $imageFileCacheManager, |
|
66
|
|
|
$options |
|
67
|
|
|
) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->repo = $repo; |
|
70
|
|
|
$this->translator = $translator; |
|
71
|
|
|
$this->imageFileCacheManager = $imageFileCacheManager; |
|
72
|
|
|
$this->jobRepo = $jobRepository; |
|
73
|
|
|
$this->options = $options; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* List organization |
|
78
|
|
|
* |
|
79
|
|
|
* @return ViewModel |
|
80
|
|
|
*/ |
|
81
|
|
|
public function indexAction() |
|
82
|
|
|
{ |
|
83
|
|
|
|
|
84
|
|
|
$result = $this->pagination([ |
|
|
|
|
|
|
85
|
|
|
'params' => ['Organizations_Profile',[ |
|
86
|
|
|
'q', |
|
87
|
|
|
'count' => $this->options['count'], |
|
88
|
|
|
'page' => 1, |
|
89
|
|
|
] |
|
90
|
|
|
], |
|
91
|
|
|
'paginator' => [ |
|
92
|
|
|
'Organizations/Organization', |
|
93
|
|
|
'as' => 'organizations', |
|
94
|
|
|
'params' => [ |
|
95
|
|
|
'type' => 'profile', |
|
96
|
|
|
] |
|
97
|
|
|
], |
|
98
|
|
|
'form' => [ |
|
99
|
|
|
'Core/Search', |
|
100
|
|
|
'as' => 'form', |
|
101
|
|
|
] |
|
102
|
|
|
]); |
|
103
|
|
|
return new ViewModel($result); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return array|ViewModel |
|
108
|
|
|
*/ |
|
109
|
|
|
public function detailAction() |
|
110
|
|
|
{ |
|
111
|
|
|
$translator = $this->translator; |
|
112
|
|
|
$repo = $this->repo; |
|
113
|
|
|
$id = $this->params('id'); |
|
114
|
|
|
|
|
115
|
|
|
if(is_null($id)){ |
|
116
|
|
|
$this->getResponse()->setStatusCode(Response::STATUS_CODE_404); |
|
|
|
|
|
|
117
|
|
|
return [ |
|
118
|
|
|
'message' => $translator->translate('Can not access profile page without id'), |
|
119
|
|
|
'exception' => new \InvalidArgumentException('Null Organization Profile Id') |
|
120
|
|
|
]; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
$organization = $repo->find($id); |
|
124
|
|
|
if(!$organization instanceof Organization){ |
|
125
|
|
|
throw new NotFoundException($id); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
if( |
|
129
|
|
|
Organization::PROFILE_DISABLED == $organization->getProfileSetting() |
|
130
|
|
|
|| is_null($organization->getProfileSetting()) |
|
131
|
|
|
){ |
|
132
|
|
|
throw new UnauthorizedAccessException(/*@translate*/ 'This Organization Profile is disabled'); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
$result = $this->pagination([ |
|
|
|
|
|
|
136
|
|
|
'params' => [ |
|
137
|
|
|
'Organization_Jobs',[ |
|
138
|
|
|
'q', |
|
139
|
|
|
'organization_id' => $organization->getId(), |
|
140
|
|
|
'count' => $this->options['count'], |
|
141
|
|
|
'page' => 1, |
|
142
|
|
|
], |
|
143
|
|
|
], |
|
144
|
|
|
'paginator' => [ |
|
145
|
|
|
'as' => 'jobs', |
|
146
|
|
|
'Organizations/ListJob', |
|
147
|
|
|
], |
|
148
|
|
|
]); |
|
149
|
|
|
|
|
150
|
|
|
if( |
|
151
|
|
|
Organization::PROFILE_ACTIVE_JOBS == $organization->getProfileSetting() |
|
152
|
|
|
){ |
|
153
|
|
|
/* @var \Zend\Paginator\Paginator $paginator */ |
|
154
|
|
|
$paginator = $result['jobs']; |
|
155
|
|
|
$count = $paginator->getTotalItemCount(); |
|
156
|
|
|
if(0===$count){ |
|
157
|
|
|
throw new UnauthorizedAccessException($this->translator->translate('This Organization Profile is disabled')); |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
$result['organization'] = $organization; |
|
161
|
|
|
$result['organizationImageCache'] = $this->imageFileCacheManager; |
|
162
|
|
|
|
|
163
|
|
|
/* @var \Zend\Mvc\Controller\Plugin\Url $url */ |
|
164
|
|
|
$result['paginationControlRoute'] = 'lang/organizations/profileDetail'; |
|
165
|
|
|
return new ViewModel($result); |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: