ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\FileUpload\Processor\PreProcessorManagerImpl Class Reference

Class PreProcessorManagerImpl. More...

+ Inheritance diagram for ILIAS\FileUpload\Processor\PreProcessorManagerImpl:
+ Collaboration diagram for ILIAS\FileUpload\Processor\PreProcessorManagerImpl:

Public Member Functions

 with (PreProcessor $processor)
 @inheritDoc More...
 
 process (FileStream $stream, Metadata $metadata)
 @inheritDoc More...
 
 with (PreProcessor $processor)
 Adds the processor to the current manager. More...
 
 process (FileStream $stream, Metadata $metadata)
 Invokes the registered processors until one rejects the file or fails. More...
 

Private Attributes

array $processors = []
 

Detailed Description

Class PreProcessorManagerImpl.

A pool of preprocessors which can be executed for a particular stream. If once of the processors fail while processing a stream, it will get rejected to protect ILIAS.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Since
5.3
Version
1.0

Definition at line 37 of file PreProcessorManagerImpl.php.

Member Function Documentation

◆ process()

ILIAS\FileUpload\Processor\PreProcessorManagerImpl::process ( FileStream  $stream,
Metadata  $metadata 
)

@inheritDoc

Implements ILIAS\FileUpload\Processor\PreProcessorManager.

Definition at line 56 of file PreProcessorManagerImpl.php.

56 : 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 }

References ILIAS\FileUpload\DTO\ProcessingStatus\DENIED, ILIAS\FileUpload\DTO\ProcessingStatus\OK, and ILIAS\FileUpload\DTO\ProcessingStatus\REJECTED.

◆ with()

ILIAS\FileUpload\Processor\PreProcessorManagerImpl::with ( PreProcessor  $processor)

@inheritDoc

Implements ILIAS\FileUpload\Processor\PreProcessorManager.

Definition at line 47 of file PreProcessorManagerImpl.php.

47 : void
48 {
49 $this->processors[] = $processor;
50 }

Field Documentation

◆ $processors

PreProcessor[] ILIAS\FileUpload\Processor\PreProcessorManagerImpl::$processors = []
private

Definition at line 42 of file PreProcessorManagerImpl.php.


The documentation for this class was generated from the following file: