ILIAS  release_8 Revision v8.24
ilObjFileAbstractProcessor Class Reference

Class ilObjFileAbstractProcessorInterface. More...

+ Inheritance diagram for ilObjFileAbstractProcessor:
+ Collaboration diagram for ilObjFileAbstractProcessor:

Public Member Functions

 __construct (ResourceStakeholder $stakeholder, ilObjFileGUI $gui_object, Services $storage, ilFileServicesSettings $settings)
 
 getInvalidFileNames ()
 
- Public Member Functions inherited from ilObjFileProcessorInterface
 process (ResourceIdentification $rid, array $options=[])
 Processes a given resource for the given arguments. More...
 

Protected Member Functions

 createFileObj (ResourceIdentification $rid, int $parent_id, array $options=[], bool $create_reference=false)
 Creates an ilObjFile instance for the provided information. More...
 
 applyOptions (ilObject $obj, array $options)
 Apply provided options to the given object. More...
 

Protected Attributes

ilFileServicesPolicy $policy
 
ilFileServicesSettings $settings
 
ilCountPDFPages $page_counter
 
Services $storage
 
ResourceStakeholder $stakeholder
 
ilObjFileGUI $gui_object
 
array $invalid_file_names = []
 

Additional Inherited Members

- Data Fields inherited from ilObjFileProcessorInterface
const OPTION_FILENAME = 'title'
 
const OPTION_DESCRIPTION = 'description'
 
const OPTIONS
 

Detailed Description

Class ilObjFileAbstractProcessorInterface.

Author
Thibeau Fuhrer thf@s.nosp@m.tude.nosp@m.r-rai.nosp@m.mann.nosp@m..ch

Definition at line 28 of file class.ilObjFileAbstractProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjFileAbstractProcessor::__construct ( ResourceStakeholder  $stakeholder,
ilObjFileGUI  $gui_object,
Services  $storage,
ilFileServicesSettings  $settings 
)

Definition at line 38 of file class.ilObjFileAbstractProcessor.php.

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 }
Class ilCountPDFPages.
Class ilFileServicesPolicy.

References $gui_object, $settings, $stakeholder, $storage, and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyOptions()

ilObjFileAbstractProcessor::applyOptions ( ilObject  $obj,
array  $options 
)
protected

Apply provided options to the given object.

Definition at line 105 of file class.ilObjFileAbstractProcessor.php.

105 : void
106 {
107 foreach ($options as $key => $option) {
108 if (in_array($key, self::OPTIONS, true)) {
109 if (!empty($option)) {
110 $setter = "set" . ucfirst($key);
111 $obj->{$setter}($option);
112 }
113 } else {
114 throw new LogicException("Option '$key' is not declared in " . static::class . "::OPTIONS.");
115 }
116 }
117 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key.

Referenced by ilObjFileAbstractZipProcessor\createContainerObj().

+ Here is the caller graph for this function:

◆ createFileObj()

ilObjFileAbstractProcessor::createFileObj ( ResourceIdentification  $rid,
int  $parent_id,
array  $options = [],
bool  $create_reference = false 
)
protected

Creates an ilObjFile instance for the provided information.

See also
ilObjFileAbstractProcessorInterface::OPTIONS

Definition at line 56 of file class.ilObjFileAbstractProcessor.php.

61 : ilObjFile {
62 $revision = $this->storage->manage()->getCurrentRevision($rid);
63 $file_obj = new ilObjFile();
64 $file_obj->setResourceId($rid);
65 if ($this->page_counter->isAvailable()) {
66 $file_obj->setPageCount($this->page_counter->extractAmountOfPagesByRID($rid) ?? 0);
67 }
68
69 $file_name = $revision->getInformation()->getTitle();
70 $title = $file_obj->appendSuffixToTitle(
71 empty($options[self::OPTION_FILENAME]) ? $file_name : $options[self::OPTION_FILENAME],
72 $file_name
73 );
74
75 $revision->setTitle($title);
76 $this->storage->manage()->updateRevision($revision);
77
78 if (!$this->policy->isValidExtension($revision->getInformation()->getSuffix())) {
79 $this->invalid_file_names[] = $title;
80 }
81 $file_obj->setTitle($title);
82 $file_obj->setFileName($title);
83 $file_obj->setVersion($revision->getVersionNumber());
84
85 if (!empty($options)) {
86 $this->applyOptions($file_obj, $options);
87 }
88
89 $file_obj->create();
90
91 ilPreview::createPreview($file_obj, true);
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 }
applyOptions(ilObject $obj, array $options)
Apply provided options to the given object.
Class ilObjFile.
static createPreview(\ilObject $a_obj, bool $a_force=false)
Creates the preview for the object with the specified id.

Referenced by ilObjFileProcessor\process(), ilObjFileUnzipFlatProcessor\process(), and ilObjFileUnzipRecursiveProcessor\process().

+ Here is the caller graph for this function:

◆ getInvalidFileNames()

ilObjFileAbstractProcessor::getInvalidFileNames ( )

Definition at line 119 of file class.ilObjFileAbstractProcessor.php.

119 : array
120 {
122 }

Field Documentation

◆ $gui_object

ilObjFileGUI ilObjFileAbstractProcessor::$gui_object
protected

◆ $invalid_file_names

array ilObjFileAbstractProcessor::$invalid_file_names = []
protected

Definition at line 36 of file class.ilObjFileAbstractProcessor.php.

◆ $page_counter

ilCountPDFPages ilObjFileAbstractProcessor::$page_counter
protected

Definition at line 32 of file class.ilObjFileAbstractProcessor.php.

◆ $policy

ilFileServicesPolicy ilObjFileAbstractProcessor::$policy
protected

Definition at line 30 of file class.ilObjFileAbstractProcessor.php.

◆ $settings

ilFileServicesSettings ilObjFileAbstractProcessor::$settings
protected

◆ $stakeholder

ResourceStakeholder ilObjFileAbstractProcessor::$stakeholder
protected

◆ $storage

Services ilObjFileAbstractProcessor::$storage
protected

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