1 | <?php |
||
65 | class ContentObject extends EzPlatformObject |
||
66 | { |
||
67 | /** |
||
68 | * @var ContentMapper |
||
69 | */ |
||
70 | private $mapper; |
||
71 | |||
72 | /** |
||
73 | * @return ContentMapper |
||
74 | */ |
||
75 | 3 | public function getMapper() |
|
83 | |||
84 | /** |
||
85 | * Constructs content object. |
||
86 | * |
||
87 | * @param array|Content $data Field data |
||
88 | * @param array $properties Additional properties |
||
89 | */ |
||
90 | 22 | public function __construct($data, array $properties = array()) |
|
91 | { |
||
92 | 22 | if ($data instanceof Content) { |
|
93 | 1 | $this->getMapper()->contentToObject($data); |
|
94 | 1 | } else { |
|
95 | 22 | parent::__construct($data, array_merge( |
|
96 | array( |
||
97 | 22 | 'main_object' => true, |
|
98 | 22 | 'parent_locations' => [], |
|
99 | 22 | ), |
|
100 | $properties |
||
101 | 22 | )); |
|
102 | } |
||
103 | |||
104 | 22 | if (isset($properties['parent_locations'])) { |
|
105 | 1 | $this->setParentLocations($properties['parent_locations']); |
|
106 | 1 | } |
|
107 | 22 | } |
|
108 | |||
109 | /** |
||
110 | * Values in array must be of type Location, LocationObject or int. |
||
111 | * |
||
112 | * @param array $parentLocations |
||
113 | */ |
||
114 | 4 | public function setParentLocations(array $parentLocations) |
|
121 | |||
122 | /** |
||
123 | * Convert parameters to LocationCreateStruct and stores it on the ContentObject. |
||
124 | * |
||
125 | * @param Location|LocationObject|int $parentLocation |
||
126 | * |
||
127 | * @throws InvalidDataStructureException |
||
128 | */ |
||
129 | 5 | public function addParentLocation($parentLocation) |
|
145 | |||
146 | /** |
||
147 | * @param int|Location|LocationObject $parentLocation |
||
148 | * |
||
149 | * @return LocationObject |
||
150 | */ |
||
151 | 5 | private function convertToLocationObject($parentLocation) |
|
169 | } |
||
170 |