ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PreProcessorManagerImpl.php
Go to the documentation of this file.
1<?php
2
20
24
38{
42 private array $processors = [];
43
47 public function with(PreProcessor $processor): void
48 {
49 $this->processors[] = $processor;
50 }
51
52
56 public function process(FileStream $stream, Metadata $metadata): ProcessingStatus
57 {
58 try {
59 $result = null;
60 foreach ($this->processors as $processor) {
61 $stream->rewind();
62 $result = $processor->process($stream, $metadata);
63 if ($result->getCode() === ProcessingStatus::REJECTED || $result->getCode() === ProcessingStatus::DENIED) {
64 return $result;
65 }
66 }
67
68 if (is_null($result)) {
69 return new ProcessingStatus(ProcessingStatus::OK, 'No processors were registered.');
70 }
71
72 return $result;
73 } catch (\Exception $ex) {
74 return new ProcessingStatus(ProcessingStatus::REJECTED, 'Processor failed with exception message "' . $ex->getMessage() . '"');
75 }
76 }
77}
process(FileStream $stream, Metadata $metadata)
@inheritDoc
The base interface for all filesystem streams.
Definition: FileStream.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...