ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjFileAbstractProcessor.php
Go to the documentation of this file.
1<?php
2
22
29{
32 protected array $invalid_file_names = [];
33
34 public function __construct(
35 protected ResourceStakeholder $stakeholder,
36 protected ilObjFileGUI $gui_object,
37 protected Services $storage,
38 protected ilFileServicesSettings $settings
39 ) {
40 $this->page_counter = new ilCountPDFPages();
41 $this->policy = new ilFileServicesPolicy($this->settings);
42 }
43
48 protected function createFileObj(
50 int $parent_id,
51 ?string $title = null,
52 ?string $description = null,
53 ?string $copyright_id = null,
54 bool $create_reference = false
55 ): ilObjFile {
56 $revision = $this->storage->manage()->getCurrentRevision($rid);
57 $file_obj = new ilObjFile();
58 $file_obj->setResourceId($rid);
59 if ($this->page_counter->isAvailable()) {
60 $file_obj->setPageCount($this->page_counter->extractAmountOfPagesByRID($rid) ?? 0);
61 }
62
63 $file_name = $revision->getInformation()->getTitle();
64 $title = $file_obj->appendSuffixToTitle(
65 $title ?? $file_name,
66 $file_name
67 );
68
69 $revision->setTitle($title);
70 $this->storage->manage()->updateRevision($revision);
71
72 if (!$this->policy->isValidExtension($revision->getInformation()->getSuffix())) {
73 $this->invalid_file_names[] = $title;
74 }
75 $file_obj->setTitle($title);
76 if ($description !== null) {
77 $file_obj->setDescription($description);
78 }
79 $file_obj->setVersion($revision->getVersionNumber());
80 $file_obj->setCopyrightID($copyright_id);
81
82 $file_obj->create();
83
84 if ($create_reference) {
85 $file_obj->createReference();
86 }
87
88 $file_obj->processAutoRating();
89 $this->gui_object->putObjectInTree($file_obj, $parent_id);
90
91 return $file_obj;
92 }
93
94 public function getInvalidFileNames(): array
95 {
96 return $this->invalid_file_names;
97 }
98}
Class ilCountPDFPages.
Class ilFileServicesPolicy.
Class ilObjFileAbstractProcessorInterface.
createFileObj(ResourceIdentification $rid, int $parent_id, ?string $title=null, ?string $description=null, ?string $copyright_id=null, bool $create_reference=false)
Creates an ilObjFile instance for the provided information.
__construct(protected ResourceStakeholder $stakeholder, protected ilObjFileGUI $gui_object, protected Services $storage, protected ilFileServicesSettings $settings)
GUI class for file objects.
Class ilObjFile.
Interface ilObjFileProcessorInterface.