ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ConsumerFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
35 {
36  protected \ILIAS\ResourceStorage\Policy\FileNamePolicy $file_name_policy;
40  private \ILIAS\HTTP\Services $http;
41  private StreamAccess $stream_access;
42 
47  public function __construct(
48  StreamAccess $stream_access,
49  FileNamePolicy $file_name_policy = null
50  ) {
51  $this->stream_access = $stream_access;
52  global $DIC;
53  $this->file_name_policy = $file_name_policy ?? new NoneFileNamePolicy();
54  $this->http = $DIC->http();
55  }
56 
57  public function download(StorableResource $resource): DownloadConsumer
58  {
59  return new DownloadConsumer(
60  $this->http,
61  $resource,
62  $this->stream_access,
63  $this->file_name_policy
64  );
65  }
66 
67  public function inline(StorableResource $resource): InlineConsumer
68  {
69  return new InlineConsumer(
70  $this->http,
71  $resource,
72  $this->stream_access,
73  $this->file_name_policy
74  );
75  }
76 
77  public function fileStream(StorableResource $resource): FileStreamConsumer
78  {
79  return new FileStreamConsumer(
80  $resource,
81  $this->stream_access
82  );
83  }
84 
88  public function absolutePath(StorableResource $resource): AbsolutePathConsumer
89  {
90  return new AbsolutePathConsumer(
91  $resource,
92  $this->stream_access,
93  $this->file_name_policy
94  );
95  }
96 
97  public function src(StorableResource $resource, SrcBuilder $src_builder): SrcConsumer
98  {
99  return new SrcConsumer(
100  $src_builder,
101  $resource,
102  $this->stream_access
103  );
104  }
105 
106  public function flavourUrl(Flavour $flavour, SrcBuilder $src_builder): FlavourURLs
107  {
108  return new FlavourURLs(
109  $src_builder,
110  $flavour
111  );
112  }
113 
114  public function downloadMultiple(
115  array $resources,
116  ?string $zip_filename = null
118  return new DownloadMultipleConsumer(
119  $resources,
120  $this->stream_access,
121  $this->file_name_policy,
122  $zip_filename ?? 'Download.zip'
123  );
124  }
125 
126  public function containerZIP(
127  StorableContainerResource $resource,
128  ): ContainerConsumer {
129  return new ContainerZIPAccessConsumer(
130  $resource,
131  $this->stream_access
132  );
133  }
134 
135  public function containerURI(
136  StorableContainerResource $resource,
137  SrcBuilder $src_builder,
138  string $start_file = 'index.html',
139  float $valid_for_at_least_minutes = 120.0
140  ): ContainerConsumer {
141  return new ContainerURIConsumer(
142  $src_builder,
143  $resource,
144  $this->stream_access,
145  $start_file,
146  $valid_for_at_least_minutes
147  );
148  }
149 }
ILIAS ResourceStorage Policy FileNamePolicy $file_name_policy
$resources
Definition: ltiservices.php:68
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)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:25
__construct(StreamAccess $stream_access, FileNamePolicy $file_name_policy=null)
ConsumerFactory constructor.
containerURI(StorableContainerResource $resource, SrcBuilder $src_builder, string $start_file='index.html', float $valid_for_at_least_minutes=120.0)
containerZIP(StorableContainerResource $resource,)
flavourUrl(Flavour $flavour, SrcBuilder $src_builder)