ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LinkGenerator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\StaticURL\Services as URLService;
26use ILIAS\Export\ExportHandler\Factory as ExportService;
27use ILIAS\Data\Factory as DataFactory;
28
30{
31 protected URLService $url_service;
32 protected ExportService $export_service;
33 protected DataFactory $data_factory;
34
35 public function __construct(
36 URLService $url_service,
37 ExportService $export_service,
38 DataFactory $data_factory
39 ) {
40 $this->url_service = $url_service;
41 $this->export_service = $export_service;
42 $this->data_factory = $data_factory;
43 }
44
45 public function generateLinkForReference(
46 int $ref_id,
47 string $type
48 ): URI {
49 $ref_id = $this->data_factory->refId($ref_id);
50 return $this->url_service->builder()->build($type, $ref_id);
51 }
52
54 int $ref_id
55 ): bool {
56 $ref_id = $this->data_factory->refId($ref_id);
57 return $this->export_service->publicAccess()->handler()->hasPublicAccessFile($ref_id->toObjectId());
58 }
59
61 int $ref_id
62 ): ?URI {
63 if (!$this->doesReferenceHavePublicAccessExport($ref_id)) {
64 return null;
65 }
66 $ref_id = $this->data_factory->refId($ref_id);
67 return $this->data_factory->uri(
68 $this->export_service->publicAccess()->handler()->downloadLinkOfPublicAccessFile($ref_id)
69 );
70 }
71}
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Class Services.
Definition: Services.php:38
$ref_id
Definition: ltiauth.php:66
if(!file_exists('../ilias.ini.php'))