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

ExpressionRouterRootResourceBuilder.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Service;
8
9 use eZ\Publish\Core\REST\Common\Values;
10 use eZ\Publish\Core\REST\Common\Values\Root;
11 use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
12 use Symfony\Component\Routing\RouterInterface;
13
33 class ExpressionRouterRootResourceBuilder implements RootResourceBuilderInterface
34 {
36 protected $router;
37
39 protected $templateRouter;
40
42 protected $resourceConfig;
43
51 public function __construct(RouterInterface $router, RouterInterface $templateRouter, array $resourceConfig)
52 {
53 $this->router = $router;
54 $this->templateRouter = $templateRouter;
55 $this->resourceConfig = $resourceConfig;
56 }
57
63 public function buildRootResource()
64 {
65 $language = new ExpressionLanguage();
66
67 $resources = [];
68 foreach ($this->resourceConfig as $name => $resource) {
69 $resources[] = new Values\Resource(
70 $name,
71 $resource['mediaType'],
72 $language->evaluate($resource['href'], [
73 'router' => $this->router,
74 'templateRouter' => $this->templateRouter,
75 ])
76 );
77 }
78
79 return new Root($resources);
80 }
81 }
eZ\Publish\Core\REST\Common\Values\Root
This class represents the root resource.
Definition: Common/Values/Root.php:15
eZ\Publish\Core\REST\Server\Service\ExpressionRouterRootResourceBuilder
Class ExpressionRouterRootResourceBuilder.
Definition: ExpressionRouterRootResourceBuilder.php:34
eZ\Publish\Core\REST\Server\Service\ExpressionRouterRootResourceBuilder\__construct
__construct(RouterInterface $router, RouterInterface $templateRouter, array $resourceConfig)
Creates a new resource builder.
Definition: ExpressionRouterRootResourceBuilder.php:51
eZ\Publish\Core\REST\Server\Service\ExpressionRouterRootResourceBuilder\$router
$router
Definition: ExpressionRouterRootResourceBuilder.php:36
eZ\Publish\Core\REST\Server\Service\ExpressionRouterRootResourceBuilder\$templateRouter
$templateRouter
Definition: ExpressionRouterRootResourceBuilder.php:39
eZ\Publish\Core\REST\Server\Service\ExpressionRouterRootResourceBuilder\buildRootResource
buildRootResource()
Build root resource.
Definition: ExpressionRouterRootResourceBuilder.php:63
eZ\Publish\Core\REST\Server\Service\ExpressionRouterRootResourceBuilder\$resourceConfig
$resourceConfig
Definition: ExpressionRouterRootResourceBuilder.php:42
eZ\Publish\Core\REST\Server\Service\RootResourceBuilderInterface
Definition: RootResourceBuilderInterface.php:10
eZ\Publish\Core\REST\Common\Values
Definition: Common/Values/ContentObjectStates.php:7
eZ\Publish\Core\REST\Server\Service
Definition: ExpressionRouterRootResourceBuilder.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.