ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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

 __construct (PreProcessorCollection $collection)
 
 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.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileUpload\Processor\PreProcessorManagerImpl::__construct ( PreProcessorCollection  $collection)

Definition at line 44 of file PreProcessorManagerImpl.php.

45 {
46 foreach ($collection->processors() as $processor) {
47 $this->processors[] = $processor;
48 }
49 }

References ILIAS\FileUpload\Processor\PreProcessorCollection\processors().

+ Here is the call graph for this function:

Member Function Documentation

◆ process()

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

@inheritDoc

Implements ILIAS\FileUpload\Processor\PreProcessorManager.

Definition at line 63 of file PreProcessorManagerImpl.php.

63 : ProcessingStatus
64 {
65 try {
66 $result = null;
67 foreach ($this->processors as $processor) {
68 $stream->rewind();
69 $result = $processor->process($stream, $metadata);
70 if ($result->getCode() === ProcessingStatus::REJECTED || $result->getCode() === ProcessingStatus::DENIED) {
71 return $result;
72 }
73 }
74
75 if (is_null($result)) {
76 return new ProcessingStatus(ProcessingStatus::OK, 'No processors were registered.');
77 }
78
79 return $result;
80 } catch (\Exception $ex) {
81 return new ProcessingStatus(ProcessingStatus::REJECTED, 'Processor failed with exception message "' . $ex->getMessage() . '"');
82 }
83 }

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

Referenced by ILIAS\FileUpload\Processor\PreProcessorManagerImplTest\testProcessWithProcessorsFromCollectionWhichShouldSucceed().

+ Here is the caller graph for this function:

◆ with()

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

@inheritDoc

Implements ILIAS\FileUpload\Processor\PreProcessorManager.

Definition at line 54 of file PreProcessorManagerImpl.php.

54 : void
55 {
56 $this->processors[] = $processor;
57 }

Referenced by ILIAS\FileUpload\Processor\PreProcessorManagerImplTest\testProcessWithProcessorsFromCollectionWhichShouldSucceed().

+ Here is the caller graph for this function:

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: