ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PreProcessorManagerImpl.php
Go to the documentation of this file.
1 <?php
2 
4 
9 
23 {
24 
28  private $processors = [];
29 
33  public function with(PreProcessor $processor)
34  {
35  $this->processors[] = $processor;
36  }
37 
38 
43  {
44  try {
45  $result = null;
46  foreach ($this->processors as $processor) {
47  $stream->rewind();
48  $result = $processor->process($stream, $metadata);
49  if ($result->getCode() === ProcessingStatus::REJECTED) {
50  return $result;
51  }
52  }
53 
54  if (is_null($result)) {
55  $result = new ProcessingStatus(ProcessingStatus::OK, 'No processors were registered.');
56  }
57 
58  return $result;
59  } catch (\Exception $ex) {
60  return new ProcessingStatus(ProcessingStatus::REJECTED, 'Processor failed with exception message "' . $ex->getMessage() . '"');
61  }
62  }
63 }
rewind()
Seek to the beginning of the stream.
const REJECTED
Upload got rejected by a processor.
$result
$metadata['__DYNAMIC:1__']
$stream
PHP stream implementation.
process(FileStream $stream, Metadata $metadata)
Interface FileStream.
Definition: FileStream.php:20