|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WebHemi. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 7.1 |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com) |
|
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
9
|
|
|
* |
|
10
|
|
|
* @link http://www.gixx-web.com |
|
11
|
|
|
*/ |
|
12
|
|
|
declare(strict_types = 1); |
|
13
|
|
|
|
|
14
|
|
|
namespace WebHemi\Middleware\Action\Website\Directory; |
|
15
|
|
|
|
|
16
|
|
|
use RuntimeException; |
|
17
|
|
|
use WebHemi\Data\Entity; |
|
18
|
|
|
use WebHemi\Middleware\Action\Website\IndexAction; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class UserAction |
|
22
|
|
|
*/ |
|
23
|
|
|
class UserAction extends IndexAction |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Gets template map name or template file path. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
|
|
public function getTemplateName() : string |
|
31
|
|
|
{ |
|
32
|
|
|
return 'website-user'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Gets template data. |
|
37
|
|
|
* |
|
38
|
|
|
* @return array |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getTemplateData() : array |
|
41
|
|
|
{ |
|
42
|
|
|
$blogPosts = []; |
|
43
|
|
|
$parameters = $this->getRoutingParameters(); |
|
44
|
|
|
|
|
45
|
|
|
$userName = $parameters['uri_parameter'] ?? ''; |
|
46
|
|
|
|
|
47
|
|
|
if (empty($userName)) { |
|
48
|
|
|
throw new RuntimeException('Forbidden', 403); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** @var Entity\User\UserEntity $userEntity */ |
|
52
|
|
|
$userEntity = $this->getUserStorage() |
|
53
|
|
|
->getUserByUserName($userName); |
|
54
|
|
|
/** @var array $userMeta */ |
|
55
|
|
|
$userMeta = $this->getUserMetaStorage() |
|
56
|
|
|
->getUserMetaArrayForUserId((int) $userEntity->getUserId()); |
|
57
|
|
|
|
|
58
|
|
|
/** @var Entity\ApplicationEntity $applicationEntity */ |
|
59
|
|
|
$applicationEntity = $this->getApplicationStorage() |
|
60
|
|
|
->getApplicationByName($this->environmentManager->getSelectedApplication()); |
|
61
|
|
|
|
|
62
|
|
|
/** @var Entity\Filesystem\FilesystemEntity[] $publications */ |
|
63
|
|
|
$publications = $this->getFilesystemStorage() |
|
64
|
|
|
->getPublishedDocumentsByAuthor($applicationEntity->getApplicationId(), $userEntity->getUserId()); |
|
65
|
|
|
|
|
66
|
|
|
/** @var Entity\Filesystem\FilesystemEntity $filesystemEntity */ |
|
67
|
|
|
foreach ($publications as $filesystemEntity) { |
|
68
|
|
|
$blogPosts[] = $this->getBlobPostData($applicationEntity, $filesystemEntity); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return [ |
|
72
|
|
|
'activeMenu' => '', |
|
73
|
|
|
'user' => [ |
|
74
|
|
|
'userId' => $userEntity->getUserId(), |
|
75
|
|
|
'userName' => $userEntity->getUserName(), |
|
76
|
|
|
'url' => $this->environmentManager->getRequestUri(), |
|
77
|
|
|
'meta' => $userMeta, |
|
78
|
|
|
], |
|
79
|
|
|
'application' => $this->getApplicationData($applicationEntity), |
|
80
|
|
|
'blogPosts' => $blogPosts, |
|
81
|
|
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|