ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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 33 of file class.ilZipJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilZipJob::__construct ( )

Construct.

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

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

42  {
43  global $DIC;
44  $this->logger = $DIC->logger()->cal();
45  $this->archives = $DIC->archives();
46  }
global $DIC
Definition: shib_login.php:26
+ 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 110 of file class.ilZipJob.php.

110  : int
111  {
112  return 30;
113  }

◆ getInputTypes()

ilZipJob::getInputTypes ( )

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ getOutputType()

ilZipJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ isStateless()

ilZipJob::isStateless ( )

Implements ILIAS\BackgroundTasks\Task\Job.

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

73  : bool
74  {
75  return true;
76  }

◆ run()

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

Todo:
use filsystem service

Implements ILIAS\BackgroundTasks\Task\Job.

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

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

83  : Value
84  {
85  $this->logger->debug('Start zipping input dir!');
86  $this->logger->dump($input);
87  $string = $input[0]->getValue();
88  $tmpdir = rtrim((string) $string, "/");
89  $this->logger->debug('Zipping directory:' . $tmpdir);
90  $zip_name = $tmpdir . '.zip';
91 
92  $zip = $this->archives->zip([]);
93  $zip->addDirectory($tmpdir);
94  $zip_stream = $zip->get();
95  stream_copy_to_stream($zip_stream->detach(), fopen($zip_name, 'wb')); // we currently have to write to disk
96 
97  // delete temp directory
98  ilFileUtils::delDir($tmpdir);
99 
100  $zip_file_name = new StringValue();
101  $zip_file_name->setValue($zip_name);
102 
103  return $zip_file_name;
104  }
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 36 of file class.ilZipJob.php.

◆ $logger

ilLogger ilZipJob::$logger
private

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


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