ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCountPDFPagesPreProcessors.php
Go to the documentation of this file.
1<?php
2
24
31{
32 public const PAGE_COUNT = 'page_count';
34
35 public function __construct()
36 {
37 $this->page_counter = new ilCountPDFPages();
38 }
39
40 public function process(FileStream $stream, Metadata $metadata): ProcessingStatus
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 }
58}
getMimeType()
Client supplied mime type of the uploaded.
Definition: Metadata.php:118
additionalMetaData()
Provides a string map implementation which allows the processors to store additional values.
Definition: Metadata.php:147
Mime type determination.
Definition: MimeType.php:30
Class ilCountPDFPagesPreProcessors.
process(FileStream $stream, Metadata $metadata)
This method gets invoked by the file upload service to process the file with the help of the processo...
Class ilCountPDFPages.
The base interface for all filesystem streams.
Definition: FileStream.php:32