ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjFileAbstractProcessor.php
Go to the documentation of this file.
1 <?php
2 
22 
29 {
33  protected Services $storage;
36  protected array $invalid_file_names = [];
37 
38  public function __construct(
39  ResourceStakeholder $stakeholder,
40  ilObjFileGUI $gui_object,
41  Services $storage,
42  ilFileServicesSettings $settings
43  ) {
44  $this->storage = $storage;
45  $this->stakeholder = $stakeholder;
46  $this->gui_object = $gui_object;
47  $this->page_counter = new ilCountPDFPages();
48  $this->settings = $settings;
49  $this->policy = new ilFileServicesPolicy($this->settings);
50  }
51 
56  protected function createFileObj(
58  int $parent_id,
59  string $title = null,
60  string $description = null,
61  int $copyright_id = null,
62  bool $create_reference = false
63  ): ilObjFile {
64  $revision = $this->storage->manage()->getCurrentRevision($rid);
65  $file_obj = new ilObjFile();
66  $file_obj->setResourceId($rid);
67  if ($this->page_counter->isAvailable()) {
68  $file_obj->setPageCount($this->page_counter->extractAmountOfPagesByRID($rid) ?? 0);
69  }
70 
71  $file_name = $revision->getInformation()->getTitle();
72  $title = $file_obj->appendSuffixToTitle(
73  $title ?? $file_name,
74  $file_name
75  );
76 
77  $revision->setTitle($title);
78  $this->storage->manage()->updateRevision($revision);
79 
80  if (!$this->policy->isValidExtension($revision->getInformation()->getSuffix())) {
81  $this->invalid_file_names[] = $title;
82  }
83  $file_obj->setTitle($title);
84  if ($description !== null) {
85  $file_obj->setDescription($description);
86  }
87  $file_obj->setVersion($revision->getVersionNumber());
88  $file_obj->setCopyrightID($copyright_id);
89 
90  $file_obj->create();
91 
92  if ($create_reference) {
93  $file_obj->createReference();
94  }
95 
96  $file_obj->processAutoRating();
97  $this->gui_object->putObjectInTree($file_obj, $parent_id);
98 
99  return $file_obj;
100  }
101 
102  public function getInvalidFileNames(): array
103  {
105  }
106 }
Class ilFileServicesPolicy.
Interface ilObjFileProcessorInterface.
__construct(ResourceStakeholder $stakeholder, ilObjFileGUI $gui_object, Services $storage, ilFileServicesSettings $settings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjFile.
createFileObj(ResourceIdentification $rid, int $parent_id, string $title=null, string $description=null, int $copyright_id=null, bool $create_reference=false)
Creates an ilObjFile instance for the provided information.
Class ilObjFileAbstractProcessorInterface.
GUI class for file objects.
Class ilCountPDFPages.