|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the package lns/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\Core\Resource\Folder; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Immutable folder object, used by getFolderItemsAction(). |
|
17
|
|
|
* |
|
18
|
|
|
* @see FolderItemFile |
|
19
|
|
|
* @see FolderItemImage |
|
20
|
|
|
*/ |
|
21
|
|
|
class TreeItemFolder implements \JsonSerializable |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string Folder name, not full path, eg. "myFolder" |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $name; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string Always set to "folder" |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $type = 'folder'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var int FAL identifier, eg. "42:/path/to/folder" |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $identifier; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Save state of folder is not part of MVP |
|
40
|
|
|
* |
|
41
|
|
|
* @var bool Folder is expanded, so children are visible, default: false |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $expanded; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var bool Folder has children |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $hasChildren; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string Public path to Icon file, currently always points to apps-filetree-folder-default.svg |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $icon = '/typo3/sysext/core/Resources/Public/Icons/T3Icons/apps/apps-filetree-folder-default.svg'; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param Folder $folder |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct(Folder $folder) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->name = $folder->getName(); |
|
61
|
|
|
$this->identifier = $folder->getCombinedIdentifier(); |
|
|
|
|
|
|
62
|
|
|
$this->expanded = false; |
|
63
|
|
|
$this->hasChildren = count($folder->getSubfolders()) > 0; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function jsonSerialize() |
|
67
|
|
|
{ |
|
68
|
|
|
return [ |
|
69
|
|
|
'name' => $this->name, |
|
70
|
|
|
'type' => $this->type, |
|
71
|
|
|
'identifier' => $this->identifier, |
|
72
|
|
|
'expanded' => $this->expanded, |
|
73
|
|
|
'hasChildren' => $this->hasChildren, |
|
74
|
|
|
'icon' => $this->icon |
|
75
|
|
|
]; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.