ILIAS  release_7 Revision v7.30-3-g800a261c036
PreProcessorManagerImpl.php
Go to the documentation of this file.
1<?php
2
20
24use Psr\Http\Message\StreamInterface;
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}
$result
An exception for terminatinating execution or to throw for unit testing.
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
Interface FileStream The base interface for all filesystem streams.
Definition: FileStream.php:18
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...