ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCountPDFPagesPreProcessors Class Reference

Class ilCountPDFPagesPreProcessors. More...

+ Inheritance diagram for ilCountPDFPagesPreProcessors:
+ Collaboration diagram for ilCountPDFPagesPreProcessors:

Public Member Functions

 __construct ()
 
 process (FileStream $stream, Metadata $metadata)
 This method gets invoked by the file upload service to process the file with the help of the processor. More...
 

Data Fields

const PAGE_COUNT = 'page_count'
 

Private Attributes

ilCountPDFPages $page_counter
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCountPDFPagesPreProcessors::__construct ( )

Definition at line 35 of file class.ilCountPDFPagesPreProcessors.php.

36  {
37  $this->page_counter = new ilCountPDFPages();
38  }
Class ilCountPDFPages.

Member Function Documentation

◆ process()

ilCountPDFPagesPreProcessors::process ( FileStream  $stream,
Metadata  $metadata 
)

This method gets invoked by the file upload service to process the file with the help of the processor.

If the return value is REJECTED, no further invocations of processors are done for the rejected file.

If the processor fails or returns an unexpected value, the file gets automatically rejected because the file could be dangerous to ILIAS.

Parameters
FileStream$streamThe stream of the file.
Metadata$metadataThe meta data of the uploaded file.
Returns
ProcessingStatus The new status of the file.

Implements ILIAS\FileUpload\Processor\PreProcessor.

Definition at line 40 of file class.ilCountPDFPagesPreProcessors.php.

References ILIAS\FileUpload\DTO\Metadata\additionalMetaData(), and ILIAS\FileUpload\DTO\Metadata\getMimeType().

41  {
42  if (
43  $this->page_counter->isAvailable()
44  && $metadata->getMimeType() === MimeType::APPLICATION__PDF
45  ) {
46  $path_to_pdf = $stream->getMetadata('uri');
47  $metadata->additionalMetaData()->put(
48  self::PAGE_COUNT,
49  (string) $this->page_counter->extractAmountOfPagesByPath($path_to_pdf)
50  );
51  }
52 
53  return new ProcessingStatus(
54  ProcessingStatus::OK,
55  'ilCountPDFPagesPreProcessors'
56  );
57  }
getMimeType()
Client supplied mime type of the uploaded.
Definition: Metadata.php:102
additionalMetaData()
Provides a string map implementation which allows the processors to store additional values...
Definition: Metadata.php:131
+ Here is the call graph for this function:

Field Documentation

◆ $page_counter

ilCountPDFPages ilCountPDFPagesPreProcessors::$page_counter
private

Definition at line 33 of file class.ilCountPDFPagesPreProcessors.php.

◆ PAGE_COUNT

const ilCountPDFPagesPreProcessors::PAGE_COUNT = 'page_count'

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