1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the package typo3/cms-digital-asset-management. |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please read the |
8
|
|
|
* LICENSE file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace TYPO3\CMS\DigitalAssetManagement\Entity; |
12
|
|
|
|
13
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
14
|
|
|
use TYPO3\CMS\Core\Resource\ResourceStorage; |
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Immutable storage object, used by getStoragesAndMountsAction() for admin users. |
19
|
|
|
* |
20
|
|
|
* @see FileMount |
21
|
|
|
*/ |
22
|
|
|
class Storage implements \JsonSerializable |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string Always set to "storage" |
26
|
|
|
*/ |
27
|
|
|
protected $type = 'storage'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var int The storage uid, eg. 42 |
31
|
|
|
*/ |
32
|
|
|
protected $identifier; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string Speaking name of storage, identical with $storageName |
36
|
|
|
*/ |
37
|
|
|
protected $name; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string Speaking name of storage, eg. "Some storage" |
41
|
|
|
*/ |
42
|
|
|
protected $storageName; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string Storage driver, eg. "Local" |
46
|
|
|
*/ |
47
|
|
|
protected $storageType; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var bool True if storage is online |
51
|
|
|
*/ |
52
|
|
|
protected $storageOnline; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string Markup of the storage icon |
56
|
|
|
*/ |
57
|
|
|
protected $icon; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
protected $editStorageUrl; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param ResourceStorage $storage |
66
|
|
|
*/ |
67
|
|
|
public function __construct(ResourceStorage $storage) |
68
|
|
|
{ |
69
|
|
|
$this->identifier = $storage->getUid(); |
70
|
|
|
$this->name = $this->storageName = $storage->getName(); |
71
|
|
|
$this->storageType = $storage->getDriverType(); |
72
|
|
|
$this->storageOnline = $storage->isOnline(); |
73
|
|
|
$this->icon = 'apps-filetree-root'; |
74
|
|
|
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
75
|
|
|
$urlParameters = [ |
76
|
|
|
'edit' => [ |
77
|
|
|
'sys_file_storage' => [ |
78
|
|
|
$storage->getUid() => 'edit', |
79
|
|
|
], |
80
|
|
|
], |
81
|
|
|
'returnUrl' => (string)$uriBuilder->buildUriFromRoute('file_DigitalAssetManagement'), |
82
|
|
|
]; |
83
|
|
|
$this->editStorageUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function jsonSerialize() |
87
|
|
|
{ |
88
|
|
|
return [ |
89
|
|
|
'type' => $this->type, |
90
|
|
|
'identifier' => $this->identifier, |
91
|
|
|
'name' => $this->name, |
92
|
|
|
'storageName' => $this->storageName, |
93
|
|
|
'storageType' => $this->storageType, |
94
|
|
|
'storageOnline' => $this->storageOnline, |
95
|
|
|
'icon' => $this->icon, |
96
|
|
|
'editStorageUrl' => $this->editStorageUrl, |
97
|
|
|
]; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|