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

BaseRelationProcessor.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Common\FieldTypeProcessor;
8
9 use eZ\Publish\API\Repository\LocationService;
10 use eZ\Publish\Core\FieldType\Relation\Type;
11 use eZ\Publish\Core\REST\Common\FieldTypeProcessor;
12 use Symfony\Component\Routing\RouterInterface;
13
14 abstract class BaseRelationProcessor extends FieldTypeProcessor
15 {
17 private $router;
18
20 private $locationService;
21
25 public function setRouter(RouterInterface $router)
26 {
27 $this->router = $router;
28 }
29
33 public function setLocationService(LocationService $locationService)
34 {
35 $this->locationService = $locationService;
36 }
37
41 public function canMapContentHref()
42 {
43 return isset($this->router);
44 }
45
51 public function mapToContentHref($contentId)
52 {
53 return $this->router->generate('ezpublish_rest_loadContent', ['contentId' => $contentId]);
54 }
55
61 public function mapToLocationHref($locationId)
62 {
63 return $this->router->generate('ezpublish_rest_loadLocation', [
64 'locationPath' => implode('/', $this->locationService->loadLocation($locationId)->path),
65 ]);
66 }
67
68 public function preProcessFieldSettingsHash($incomingSettingsHash)
69 {
70 if (isset($incomingSettingsHash['selectionMethod'])) {
71 switch ($incomingSettingsHash['selectionMethod']) {
72 case 'SELECTION_BROWSE':
73 $incomingSettingsHash['selectionMethod'] = Type::SELECTION_BROWSE;
74 break;
75 case 'SELECTION_DROPDOWN':
76 $incomingSettingsHash['selectionMethod'] = Type::SELECTION_DROPDOWN;
77 }
78 }
79
80 return $incomingSettingsHash;
81 }
82
83 public function postProcessFieldSettingsHash($outgoingSettingsHash)
84 {
85 if (isset($outgoingSettingsHash['selectionMethod'])) {
86 switch ($outgoingSettingsHash['selectionMethod']) {
87 case Type::SELECTION_BROWSE:
88 $outgoingSettingsHash['selectionMethod'] = 'SELECTION_BROWSE';
89 break;
90 case Type::SELECTION_DROPDOWN:
91 $outgoingSettingsHash['selectionMethod'] = 'SELECTION_DROPDOWN';
92 }
93 }
94
95 return $outgoingSettingsHash;
96 }
97 }
eZ\Publish\Core\FieldType\Relation\Type
The Relation field type.
Definition: Core/FieldType/Relation/Type.php:30
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor
Definition: BaseRelationProcessor.php:15
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\mapToContentHref
mapToContentHref($contentId)
Definition: BaseRelationProcessor.php:51
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\canMapContentHref
canMapContentHref()
Definition: BaseRelationProcessor.php:41
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\mapToLocationHref
mapToLocationHref($locationId)
Definition: BaseRelationProcessor.php:61
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\setRouter
setRouter(RouterInterface $router)
Definition: BaseRelationProcessor.php:25
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\preProcessFieldSettingsHash
preProcessFieldSettingsHash($incomingSettingsHash)
Perform manipulations on a received $incomingSettingsHash.
Definition: BaseRelationProcessor.php:68
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\$locationService
$locationService
Definition: BaseRelationProcessor.php:20
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\$router
$router
Definition: BaseRelationProcessor.php:17
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\setLocationService
setLocationService(LocationService $locationService)
Definition: BaseRelationProcessor.php:33
eZ\Publish\Core\REST\Common\FieldTypeProcessor\BaseRelationProcessor\postProcessFieldSettingsHash
postProcessFieldSettingsHash($outgoingSettingsHash)
Perform manipulations on a received $outgoingSettingsHash.
Definition: BaseRelationProcessor.php:83
eZ\Publish\Core\REST\Common\FieldTypeProcessor
FieldTypeProcessor.
Definition: FieldTypeProcessor.php:13
eZ\Publish\API\Repository\LocationService
Definition: API/Repository/LocationService.php:21
eZ\Publish\Core\REST\Common\FieldTypeProcessor
Definition: AuthorProcessor.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.