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

ContentDownloadUrlGenerator.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase;
8
9 use eZ\Publish\SPI\FieldType\BinaryBase\PathGenerator;
10 use eZ\Publish\SPI\FieldType\BinaryBase\RouteAwarePathGenerator;
11 use eZ\Publish\SPI\Persistence\Content\Field;
12 use eZ\Publish\SPI\Persistence\Content\VersionInfo;
13 use Symfony\Component\Routing\RouterInterface;
14
15 class ContentDownloadUrlGenerator extends PathGenerator implements RouteAwarePathGenerator
16 {
18 private $router;
19
21 private $route = 'ez_content_download_field_id';
22
23 public function __construct(RouterInterface $router)
24 {
25 $this->router = $router;
26 }
27
28 public function getStoragePathForField(Field $field, VersionInfo $versionInfo)
29 {
30 return $this->generate($this->route, $this->getParameters($field, $versionInfo));
31 }
32
33 public function generate(string $route, ?array $parameters = []): string
34 {
35 return $this->router->generate($route, $parameters ?? []);
36 }
37
38 public function getRoute(Field $field, VersionInfo $versionInfo): string
39 {
40 return $this->route;
41 }
42
43 public function getParameters(Field $field, VersionInfo $versionInfo): array
44 {
45 return [
46 'contentId' => $versionInfo->contentInfo->id,
47 'fieldId' => $field->id,
48 'version' => $versionInfo->versionNo,
49 ];
50 }
51 }
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator
Definition: ContentDownloadUrlGenerator.php:16
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\getRoute
getRoute(Field $field, VersionInfo $versionInfo)
Definition: ContentDownloadUrlGenerator.php:38
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\generate
generate(string $route, ?array $parameters=[])
Definition: ContentDownloadUrlGenerator.php:33
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\__construct
__construct(RouterInterface $router)
Definition: ContentDownloadUrlGenerator.php:23
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\$router
$router
Definition: ContentDownloadUrlGenerator.php:18
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\$route
$route
Definition: ContentDownloadUrlGenerator.php:21
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\getParameters
getParameters(Field $field, VersionInfo $versionInfo)
Definition: ContentDownloadUrlGenerator.php:43
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase\ContentDownloadUrlGenerator\getStoragePathForField
getStoragePathForField(Field $field, VersionInfo $versionInfo)
Definition: ContentDownloadUrlGenerator.php:28
eZ\Publish\SPI\FieldType\BinaryBase\PathGenerator
Definition: SPI/FieldType/BinaryBase/PathGenerator.php:16
eZ\Publish\SPI\Persistence\Content\Field
Definition: SPI/Persistence/Content/Field.php:12
eZ\Publish\SPI\Persistence\Content\VersionInfo
This class holds version information data.
Definition: SPI/Persistence/Content/VersionInfo.php:15
eZ\Publish\SPI\FieldType\BinaryBase\RouteAwarePathGenerator
A variant of PathGenerator that uses Symfony routes for generating URIs.
Definition: RouteAwarePathGenerator.php:18
eZ\Publish\Core\MVC\Symfony\FieldType\BinaryBase
Definition: ContentDownloadUrlGenerator.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.