ILIAS  release_8 Revision v8.23
ConsumerFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
33 {
34  protected \ILIAS\ResourceStorage\Policy\FileNamePolicy $file_name_policy;
38  private \ILIAS\HTTP\Services $http;
40 
45  public function __construct(
46  StreamAccess $stream_access,
47  FileNamePolicy $file_name_policy = null
48  ) {
49  $this->stream_access = $stream_access;
50  global $DIC;
51  $this->file_name_policy = $file_name_policy ?? new NoneFileNamePolicy();
52  $this->http = $DIC->http();
53  }
54 
55  public function download(StorableResource $resource): DownloadConsumer
56  {
57  return new DownloadConsumer(
58  $this->http,
59  $resource,
60  $this->stream_access,
61  $this->file_name_policy
62  );
63  }
64 
65  public function inline(StorableResource $resource): InlineConsumer
66  {
67  return new InlineConsumer(
68  $this->http,
69  $resource,
70  $this->stream_access,
71  $this->file_name_policy
72  );
73  }
74 
75  public function fileStream(StorableResource $resource): FileStreamConsumer
76  {
77  return new FileStreamConsumer(
78  $resource,
79  $this->stream_access
80  );
81  }
82 
87  {
88  return new AbsolutePathConsumer(
89  $resource,
90  $this->stream_access,
91  $this->file_name_policy
92  );
93  }
94 
95  public function src(StorableResource $resource, SrcBuilder $src_builder): SrcConsumer
96  {
97  return new SrcConsumer(
98  $src_builder,
99  $resource,
100  $this->stream_access
101  );
102  }
103 
104  public function downloadMultiple(
105  array $resources,
106  ?string $zip_filename = null
108  return new DownloadMultipleConsumer(
109  $resources,
110  $this->stream_access,
111  $this->file_name_policy,
112  $zip_filename ?? 'Download.zip'
113  );
114  }
115 }
$resources
Definition: ltiservices.php:68
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS ResourceStorage Policy FileNamePolicy $file_name_policy
downloadMultiple(array $resources, ?string $zip_filename=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
src(StorableResource $resource, SrcBuilder $src_builder)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(StreamAccess $stream_access, FileNamePolicy $file_name_policy=null)
ConsumerFactory constructor.