ILIAS  release_8 Revision v8.24
PreProcessorManagerImpl.php
Go to the documentation of this file.
1<?php
2
20
24use Psr\Http\Message\StreamInterface;
25
39{
43 private array $processors = [];
44
48 public function with(PreProcessor $processor): void
49 {
50 $this->processors[] = $processor;
51 }
52
53
57 public function process(FileStream $stream, Metadata $metadata): ProcessingStatus
58 {
59 try {
60 $result = null;
61 foreach ($this->processors as $processor) {
62 $stream->rewind();
63 $result = $processor->process($stream, $metadata);
64 if ($result->getCode() === ProcessingStatus::REJECTED || $result->getCode() === ProcessingStatus::DENIED) {
65 return $result;
66 }
67 }
68
69 if (is_null($result)) {
70 $result = new ProcessingStatus(ProcessingStatus::OK, 'No processors were registered.');
71 }
72
73 return $result;
74 } catch (\Exception $ex) {
75 return new ProcessingStatus(ProcessingStatus::REJECTED, 'Processor failed with exception message "' . $ex->getMessage() . '"');
76 }
77 }
78}
const REJECTED
Upload got rejected by a processor.
const DENIED
Upload got denied by a processor, the upload will be removed immediately.
process(FileStream $stream, Metadata $metadata)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...