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\Traits; |
15
|
|
|
|
16
|
|
|
use WebHemi\Data\Entity; |
17
|
|
|
use WebHemi\Data\Storage; |
18
|
|
|
use WebHemi\Router\ProxyInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Trait GetPublicationCategoryTrait |
22
|
|
|
*/ |
23
|
|
|
trait GetPublicationCategoryTrait |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @return null|Storage\Filesystem\FilesystemCategoryStorage |
27
|
|
|
*/ |
28
|
|
|
abstract protected function getFilesystemCategoryStorage() : ? Storage\Filesystem\FilesystemCategoryStorage; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @return null|Storage\Filesystem\FilesystemDirectoryStorage |
32
|
|
|
*/ |
33
|
|
|
abstract protected function getFilesystemDirectoryStorage() : ? Storage\Filesystem\FilesystemDirectoryStorage; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Gets the category for a filesystem record. |
37
|
|
|
* |
38
|
|
|
* @param int $applicationId |
39
|
|
|
* @param int $categoryId |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
|
|
protected function getPublicationCategory(int $applicationId, int $categoryId) : array |
43
|
|
|
{ |
44
|
|
|
/** @var Entity\Filesystem\FilesystemCategoryEntity $categoryEntity */ |
45
|
|
|
$categoryEntity = $this->getFilesystemCategoryStorage() |
46
|
|
|
->getFilesystemCategoryById($categoryId); |
47
|
|
|
|
48
|
|
|
/** @var array $categoryDirectoryData */ |
49
|
|
|
$categoryDirectoryData = $this->getFilesystemDirectoryStorage() |
50
|
|
|
->getDirectoryDataByApplicationAndProxy($applicationId, ProxyInterface::LIST_CATEGORY); |
51
|
|
|
|
52
|
|
|
$category = [ |
53
|
|
|
'url' => $categoryDirectoryData['uri'].'/'.$categoryEntity->getName(), |
54
|
|
|
'name' => $categoryEntity->getName(), |
55
|
|
|
'title' => $categoryEntity->getTitle() |
56
|
|
|
]; |
57
|
|
|
return $category; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|