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