ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilZipJob Class Reference

Description of class class. More...

+ Inheritance diagram for ilZipJob:
+ Collaboration diagram for ilZipJob:

Public Member Functions

 __construct ()
 Construct. More...
 
 getInputTypes ()
 
 getOutputType ()
 
 isStateless ()
 
 run (array $input, Observer $observer)
 
 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
array returns the input array
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...
 

Private Attributes

ilLogger $logger
 
Archives $archives
 

Additional Inherited Members

- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes (array $values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
Value $output
 

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 32 of file class.ilZipJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilZipJob::__construct ( )

Construct.

Definition at line 40 of file class.ilZipJob.php.

References $DIC, and ILIAS\Repository\logger().

41  {
42  global $DIC;
43  $this->logger = $DIC->logger()->cal();
44  $this->archives = $DIC->archives();
45  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getExpectedTimeOfTaskInSeconds()

ilZipJob::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 109 of file class.ilZipJob.php.

109  : int
110  {
111  return 30;
112  }

◆ getInputTypes()

ilZipJob::getInputTypes ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 51 of file class.ilZipJob.php.

51  : array
52  {
53  return
54  [
55  new SingleType(StringValue::class),
56  ];
57  }

◆ getOutputType()

ilZipJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 63 of file class.ilZipJob.php.

63  : Type
64  {
65  return new SingleType(StringValue::class);
66  }

◆ isStateless()

ilZipJob::isStateless ( )

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 72 of file class.ilZipJob.php.

72  : bool
73  {
74  return true;
75  }

◆ run()

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

Todo:
use filsystem service

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 82 of file class.ilZipJob.php.

References ilFileUtils\delDir(), and ILIAS\Repository\logger().

82  : Value
83  {
84  $this->logger->debug('Start zipping input dir!');
85  $this->logger->dump($input);
86  $string = $input[0]->getValue();
87  $tmpdir = rtrim((string) $string, "/");
88  $this->logger->debug('Zipping directory:' . $tmpdir);
89  $zip_name = $tmpdir . '.zip';
90 
91  $zip = $this->archives->zip([]);
92  $zip->addDirectory($tmpdir);
93  $zip_stream = $zip->get();
94  stream_copy_to_stream($zip_stream->detach(), fopen($zip_name, 'wb')); // we currently have to write to disk
95 
96  // delete temp directory
97  ilFileUtils::delDir($tmpdir);
98 
99  $zip_file_name = new StringValue();
100  $zip_file_name->setValue($zip_name);
101 
102  return $zip_file_name;
103  }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

Field Documentation

◆ $archives

Archives ilZipJob::$archives
private

Definition at line 35 of file class.ilZipJob.php.

◆ $logger

ilLogger ilZipJob::$logger
private

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


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