1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the eZ\Publish\Core\Repository\Values\Content\Location class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\Repository\Values\Content; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\Content\Location as APILocation; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This class represents a location in the repository. |
15
|
|
|
* |
16
|
|
|
* @internal Meant for internal use by Repository, type hint against API object instead. |
17
|
|
|
*/ |
18
|
|
|
class Location extends APILocation |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Content info of the content object of this location. |
22
|
|
|
* |
23
|
|
|
* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo |
24
|
|
|
*/ |
25
|
|
|
protected $contentInfo; |
26
|
|
|
|
27
|
|
|
/** @var array */ |
28
|
|
|
protected $path; |
29
|
|
|
|
30
|
|
|
/** @var \eZ\Publish\API\Repository\Values\Content\Location|null */ |
31
|
|
|
protected $parentLocation; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Returns the content info of the content object of this location. |
35
|
|
|
* |
36
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
37
|
|
|
*/ |
38
|
|
|
public function getContentInfo() |
39
|
|
|
{ |
40
|
|
|
return $this->contentInfo; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getParentLocation(): ?APILocation |
44
|
|
|
{ |
45
|
|
|
return $this->parentLocation; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Function where list of properties are returned. |
50
|
|
|
* |
51
|
|
|
* Override to add dynamic properties |
52
|
|
|
* |
53
|
|
|
* @uses \parent::getProperties() |
54
|
|
|
* |
55
|
|
|
* @param array $dynamicProperties |
56
|
|
|
* |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
protected function getProperties($dynamicProperties = ['contentId']) |
60
|
|
|
{ |
61
|
|
|
return parent::getProperties($dynamicProperties); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Magic getter for retrieving convenience properties. |
66
|
|
|
* |
67
|
|
|
* @param string $property The name of the property to retrieve |
68
|
|
|
* |
69
|
|
|
* @return mixed |
70
|
|
|
*/ |
71
|
|
|
public function __get($property) |
72
|
|
|
{ |
73
|
|
|
switch ($property) { |
74
|
|
|
case 'contentId': |
75
|
|
|
return $this->contentInfo->id; |
76
|
|
|
case 'path': |
77
|
|
|
if ($this->path !== null) { |
78
|
|
|
return $this->path; |
79
|
|
|
} |
80
|
|
|
if (isset($this->pathString[1]) && $this->pathString[0] === '/') { |
81
|
|
|
return $this->path = explode('/', trim($this->pathString, '/')); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $this->path = []; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return parent::__get($property); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Magic isset for signaling existence of convenience properties. |
92
|
|
|
* |
93
|
|
|
* @param string $property |
94
|
|
|
* |
95
|
|
|
* @return bool |
96
|
|
|
*/ |
97
|
|
|
public function __isset($property) |
98
|
|
|
{ |
99
|
|
|
if ($property === 'contentId' || $property === 'path') { |
100
|
|
|
return true; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
return parent::__isset($property); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|