ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
PreProcessorManagerImpl.php
Go to the documentation of this file.
1 <?php
2 
20 
25 
39 {
40 
44  private $processors = [];
45 
49  public function with(PreProcessor $processor)
50  {
51  $this->processors[] = $processor;
52  }
53 
54 
58  public function process(FileStream $stream, Metadata $metadata)
59  {
60  try {
61  $result = null;
62  foreach ($this->processors as $processor) {
63  $stream->rewind();
64  $result = $processor->process($stream, $metadata);
65  if ($result->getCode() === ProcessingStatus::REJECTED || $result->getCode() === ProcessingStatus::DENIED) {
66  return $result;
67  }
68  }
69 
70  if (is_null($result)) {
71  $result = new ProcessingStatus(ProcessingStatus::OK, 'No processors were registered.');
72  }
73 
74  return $result;
75  } catch (\Exception $ex) {
76  return new ProcessingStatus(ProcessingStatus::REJECTED, 'Processor failed with exception message "' . $ex->getMessage() . '"');
77  }
78  }
79 }
const REJECTED
Upload got rejected by a processor.
$result
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const DENIED
Upload got denied by a processor, the upload will be removed immediately.
process(FileStream $stream, Metadata $metadata)
Interface FileStream The base interface for all filesystem streams.
Definition: FileStream.php:17