Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Publish/Core/Persistence/Legacy/Content/Location/Mapper.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Persistence\Legacy\Content\Location;
8
9 use eZ\Publish\SPI\Persistence\Content\Location;
10 use eZ\Publish\SPI\Persistence\Content\Location\CreateStruct;
11
15 class Mapper
16 {
30 public function createLocationFromRow(array $data, $prefix = '', ?Location $location = null)
31 {
32 $location = $location ?: new Location();
33
34 $location->id = (int)$data[$prefix . 'node_id'];
35 $location->priority = (int)$data[$prefix . 'priority'];
36 $location->hidden = (bool)$data[$prefix . 'is_hidden'];
37 $location->invisible = (bool)$data[$prefix . 'is_invisible'];
38 $location->remoteId = $data[$prefix . 'remote_id'];
39 $location->contentId = (int)$data[$prefix . 'contentobject_id'];
40 $location->parentId = (int)$data[$prefix . 'parent_node_id'];
41 $location->pathIdentificationString = $data[$prefix . 'path_identification_string'];
42 $location->pathString = $data[$prefix . 'path_string'];
43 $location->depth = (int)$data[$prefix . 'depth'];
44 $location->sortField = (int)$data[$prefix . 'sort_field'];
45 $location->sortOrder = (int)$data[$prefix . 'sort_order'];
46 if (isset($data[$prefix . 'trashed'])) {
47 $location->trashed = (int)$data[$prefix . 'trashed'];
48 }
49
50 return $location;
51 }
52
63 public function createLocationsFromRows(array $rows, $prefix = '', ?Location $location = null)
64 {
65 $locations = [];
66
67 foreach ($rows as $row) {
68 $id = $row[$prefix . 'node_id'];
69 if (!isset($locations[$id])) {
70 $locations[$id] = $this->createLocationFromRow($row, $prefix, $location);
71 }
72 }
73
74 return array_values($locations);
75 }
76
84 public function getLocationCreateStruct(array $data)
85 {
86 $struct = new CreateStruct();
87
88 $struct->contentId = $data['contentobject_id'];
89 $struct->contentVersion = $data['contentobject_version'];
90 $struct->hidden = $data['is_hidden'];
91 $struct->invisible = $data['is_invisible'];
92 $struct->mainLocationId = $data['main_node_id'];
93 $struct->parentId = $data['parent_node_id'];
94 $struct->pathIdentificationString = $data['path_identification_string'];
95 $struct->priority = $data['priority'];
96 $struct->remoteId = md5(uniqid(get_class($this), true));
97 $struct->sortField = $data['sort_field'];
98 $struct->sortOrder = $data['sort_order'];
99
100 return $struct;
101 }
102 }
eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper
Mapper for Location objects.
Definition: Publish/Core/Persistence/Legacy/Content/Location/Mapper.php:16
eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper\getLocationCreateStruct
getLocationCreateStruct(array $data)
Creates a Location CreateStruct from a $data row.
Definition: Publish/Core/Persistence/Legacy/Content/Location/Mapper.php:84
eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper\createLocationFromRow
createLocationFromRow(array $data, $prefix='', ?Location $location=null)
Creates a Location from a $data row.
Definition: Publish/Core/Persistence/Legacy/Content/Location/Mapper.php:30
eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper\createLocationsFromRows
createLocationsFromRows(array $rows, $prefix='', ?Location $location=null)
Creates Location objects from the given $rows, optionally with key $prefix.
Definition: Publish/Core/Persistence/Legacy/Content/Location/Mapper.php:63
eZ\Publish\SPI\Persistence\Content\CreateStruct
Definition: SPI/Persistence/Content/CreateStruct.php:12
eZ\Publish\SPI\Persistence\Content\Location\CreateStruct
Definition: SPI/Persistence/Content/Location/CreateStruct.php:12
eZ\Publish\SPI\Persistence\Content\Location
Struct containing accessible properties on Location entities.
Definition: SPI/Persistence/Content/Location.php:15
eZ\Publish\SPI\Persistence\Content\Location\$id
$id
Definition: SPI/Persistence/Content/Location.php:39
eZ\Publish\SPI\Persistence\Content\Location
Definition: SPI/Persistence/Content/Location/CreateStruct.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.