ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarCopyFilesToTempDirectoryJob Class Reference

Description of class class. More...

+ Inheritance diagram for ilCalendarCopyFilesToTempDirectoryJob:
+ Collaboration diagram for ilCalendarCopyFilesToTempDirectoryJob:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getInputTypes ()
 
 getOutputType ()
 
 isStateless ()
 
 run (array $input, Observer $observer)
 run the job More...
 
 getExpectedTimeOfTaskInSeconds ()
 
Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
Value[]
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 
 getType ()
 
 getInputTypes ()
 
 getOutputType ()
 
 getOutput ()
 
 setInput (array $values)
 
 getInput ()
 
 unfoldTask ()
 
 getRemoveOption ()
 
 getAbortOption ()
 
 run (array $input, Observer $observer)
 
 isStateless ()
 
 getInput ()
 
 getExpectedTimeOfTaskInSeconds ()
 

Protected Member Functions

 createUniqueTempDirectory ()
 
 createTargetDirectory ($a_tmpdir)
 
 copyFiles ($tmpdir, ilCalendarCopyDefinition $definition)
 Copy files. More...
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes ($values)
 
 extractType ($value)
 

Protected Attributes

 $target_directory
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 $input = []
 
 $output
 

Private Attributes

 $logger = null
 

Additional Inherited Members

- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 

Detailed Description

Description of class class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 19 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCopyFilesToTempDirectoryJob::__construct ( )

Constructor.

Definition at line 34 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

35 {
36 $this->logger = $GLOBALS['DIC']->logger()->cal();
37 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS.

Member Function Documentation

◆ copyFiles()

ilCalendarCopyFilesToTempDirectoryJob::copyFiles (   $tmpdir,
ilCalendarCopyDefinition  $definition 
)
protected

Copy files.

Parameters
string$tmpdir
ilCalendarCopyDefinition$definition

Definition at line 126 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

127 {
128 foreach ($definition->getCopyDefinitions() as $copy_task) {
129 if (!file_exists($copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR])) {
130 $this->logger->notice('Cannot find file: ' . $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR]);
131 continue;
132 }
133 $this->logger->debug('Creating directory: ' . $tmpdir . '/' . dirname($copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]));
135 $tmpdir . '/' . dirname($copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR])
136 );
137
138 $this->logger->debug(
139 'Copying from: ' .
141 ' to ' .
142 $tmpdir . '/' . $copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]
143 );
144
145 copy(
147 $tmpdir . '/' . $copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]
148 );
149 }
150 return;
151 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilCalendarCopyDefinition\COPY_SOURCE_DIR, ilCalendarCopyDefinition\COPY_TARGET_DIR, ilCalendarCopyDefinition\getCopyDefinitions(), and ilUtil\makeDirParents().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTargetDirectory()

ilCalendarCopyFilesToTempDirectoryJob::createTargetDirectory (   $a_tmpdir)
protected

Definition at line 113 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

114 {
115 $final_dir = $a_tmpdir . "/" . $this->target_directory;
116 ilUtil::makeDirParents($final_dir);
117 $this->logger->info('New final directory: ' . $final_dir);
118 return $final_dir;
119 }

References $target_directory, and ilUtil\makeDirParents().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createUniqueTempDirectory()

ilCalendarCopyFilesToTempDirectoryJob::createUniqueTempDirectory ( )
protected
Todo:
refactor to new file system access Create unique temp directory
Returns
string absolute path to new temp directory

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

106 {
107 $tmpdir = ilUtil::ilTempnam();
108 ilUtil::makeDirParents($tmpdir);
109 $this->logger->info('New temp directory: ' . $tmpdir);
110 return $tmpdir;
111 }
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.

References ilUtil\ilTempnam(), and ilUtil\makeDirParents().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpectedTimeOfTaskInSeconds()

ilCalendarCopyFilesToTempDirectoryJob::getExpectedTimeOfTaskInSeconds ( )

Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 157 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

158 {
159 return 30;
160 }

◆ getInputTypes()

ilCalendarCopyFilesToTempDirectoryJob::getInputTypes ( )
Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 41 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

42 {
43 return
44 [
45 new SingleType(ilCalendarCopyDefinition::class)
46 ];
47 }

◆ getOutputType()

ilCalendarCopyFilesToTempDirectoryJob::getOutputType ( )
Todo:
output should be file type
Returns
SingleType

Implements ILIAS\BackgroundTasks\Task.

Definition at line 53 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

54 {
55 return new SingleType(StringValue::class);
56 }

◆ isStateless()

ilCalendarCopyFilesToTempDirectoryJob::isStateless ( )
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 58 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

59 {
60 return true;
61 }

◆ run()

ilCalendarCopyFilesToTempDirectoryJob::run ( array  $input,
Observer  $observer 
)

run the job

Parameters
array$input
Observer$observer
Returns
StringValue
Exceptions

ILIAS\BackgroundTasks\Exceptions\InvalidArgumentException

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 73 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

74 {
75 $cal_copy_def = $input[0];
76
77 $this->logger->info('Called copy files job');
78
79 $this->target_directory = $cal_copy_def->getTempDir();
80 //$this->target_directory = $input[1]->getValue();
81
82 // create temp directory
83 $tmpdir = $this->createUniqueTempDirectory();
84 $targetdir = $this->createTargetDirectory($tmpdir);
85
86 // copy files from source to temp directory
87 //$this->copyFiles($targetdir, $input[0]);
88 $this->copyFiles($targetdir, $cal_copy_def);
89
90 // zip
91
92 // return zip file name
93 $this->logger->debug('Returning new tempdirectory: ' . $targetdir);
94
95 $out = new StringValue();
96 $out->setValue($targetdir);
97 return $out;
98 }
copyFiles($tmpdir, ilCalendarCopyDefinition $definition)
Copy files.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, $out, copyFiles(), createTargetDirectory(), and createUniqueTempDirectory().

+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilCalendarCopyFilesToTempDirectoryJob::$logger = null
private

◆ $target_directory

ilCalendarCopyFilesToTempDirectoryJob::$target_directory
protected

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