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

HttpUtils.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\Security;
8
9 use eZ\Publish\Core\MVC\Symfony\SiteAccess;
10 use eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
11 use Symfony\Component\HttpFoundation\Request;
12 use Symfony\Component\Security\Http\HttpUtils as BaseHttpUtils;
13
14 class HttpUtils extends BaseHttpUtils implements SiteAccessAware
15 {
17 private $siteAccess;
18
22 public function setSiteAccess(SiteAccess $siteAccess = null)
23 {
24 $this->siteAccess = $siteAccess;
25 }
26
27 private function analyzeLink($path)
28 {
29 if ($path[0] === '/' && $this->siteAccess->matcher instanceof SiteAccess\URILexer) {
30 $path = $this->siteAccess->matcher->analyseLink($path);
31 }
32
33 return $path;
34 }
35
36 public function generateUri($request, $path)
37 {
38 if ($this->isRouteName($path)) {
39 // Remove siteaccess attribute to avoid triggering reverse siteaccess lookup during link generation.
40 $request->attributes->remove('siteaccess');
41 }
42
43 return parent::generateUri($request, $this->analyzeLink($path));
44 }
45
46 public function checkRequestPath(Request $request, $path)
47 {
48 return parent::checkRequestPath($request, $this->analyzeLink($path));
49 }
50
56 private function isRouteName($path)
57 {
58 return $path && strpos($path, 'http') !== 0 && strpos($path, '/') !== 0;
59 }
60 }
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils
Definition: HttpUtils.php:15
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils\generateUri
generateUri($request, $path)
Definition: HttpUtils.php:36
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils\checkRequestPath
checkRequestPath(Request $request, $path)
Definition: HttpUtils.php:46
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils\isRouteName
isRouteName($path)
Definition: HttpUtils.php:56
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils\$siteAccess
$siteAccess
Definition: HttpUtils.php:17
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils\setSiteAccess
setSiteAccess(SiteAccess $siteAccess=null)
Definition: HttpUtils.php:22
eZ\Publish\Core\MVC\Symfony\Security\HttpUtils\analyzeLink
analyzeLink($path)
Definition: HttpUtils.php:27
eZ\Publish\Core\MVC\Symfony\SiteAccess
Base struct for a siteaccess representation.
Definition: SiteAccess.php:16
eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessAware
Interface for SiteAccess aware services.
Definition: SiteAccessAware.php:15
eZ\Publish\Core\MVC\Symfony\SiteAccess\URILexer
Interface for SiteAccess matchers that need to alter the URI after matching.
Definition: URILexer.php:14
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.