ILIAS  release_8 Revision v8.23
ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction Class Reference
+ Inheritance diagram for ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction:
+ Collaboration diagram for ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction:

Public Member Functions

 __construct ()
 
 getInputTypes ()
 
 getRemoveOption ()
 
 getOutputType ()
 
 getOptions (array $input)
 
 interaction (array $input, Option $user_selected_option, Bucket $bucket)
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractUserInteraction
 getMessage (array $input)
 
 canBeSkipped (array $input)
 
 getSkippedValue (array $input)
 
 isFinal ()
 
- 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...
 

Data Fields

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

Private Attributes

ilLogger $logger = null
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes ($values)
 
 extractType ($value)
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
ILIAS BackgroundTasks Value $output
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 34 of file DownloadAllZipInteraction.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::__construct ( )

Definition at line 41 of file DownloadAllZipInteraction.php.

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

42  {
43  global $DIC;
44 
45  $this->logger = $DIC->logger()->mcst();
46  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ getInputTypes()

ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::getInputTypes ( )
Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 48 of file DownloadAllZipInteraction.php.

48  : array
49  {
50  return [
51  new SingleType(StringValue::class),
52  new SingleType(StringValue::class)
53  ];
54  }

◆ getOptions()

ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::getOptions ( array  $input)
Parameters
Value[]$input The input value of this task.
Returns
Option[] Options are buttons the user can press on this interaction.

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

Definition at line 67 of file DownloadAllZipInteraction.php.

67  : array
68  {
69  return [
70  new UserInteractionOption('download', self::OPTION_DOWNLOAD)
71  ];
72  }

◆ getOutputType()

ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 62 of file DownloadAllZipInteraction.php.

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

◆ getRemoveOption()

ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::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();

Implements ILIAS\BackgroundTasks\Task.

Definition at line 57 of file DownloadAllZipInteraction.php.

57  : UserInteractionOption
58  {
59  return new UserInteractionOption('remove', self::OPTION_CANCEL);
60  }

◆ interaction()

ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::interaction ( array  $input,
Option  $user_selected_option,
Bucket  $bucket 
)
Parameters

Implements ILIAS\BackgroundTasks\Task\UserInteraction.

Definition at line 74 of file DownloadAllZipInteraction.php.

References $DIC, Vendor\Package\$e, $path, ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath(), ilFileDelivery\deliverFileAttached(), ILIAS\BackgroundTasks\Task\UserInteraction\Option\getValue(), and ILIAS\Repository\logger().

79  global $DIC;
80  $download_name = $input[0]; //directory name.
81  $zip_name = $input[1]; // zip job
82 
83  $this->logger->debug("Interaction -> input[0] download name MUST BE FULL PATH=> " . $download_name->getValue());
84  $this->logger->debug("Interaction -> input[1] zip name MUST BE THE NAME WITHOUT EXTENSION. => " . $zip_name->getValue());
85 
86  if ($user_selected_option->getValue() != self::OPTION_DOWNLOAD) {
87  $this->logger->info('Download canceled');
88  // delete zip file
89  $filesystem = $DIC->filesystem()->temp();
90  try {
91  $path = LegacyPathHelper::createRelativePath($zip_name->getValue());
92  } catch (\InvalidArgumentException $e) {
93  $path = null;
94  }
95  if (!is_null($path) && $filesystem->has($path)) {
96  $filesystem->deleteDir(dirname($path));
97  }
98 
99  return new ThunkValue();
100  }
101 
102  $this->logger->info("Delivering File.");
103 
104 
105  $zip_name = $zip_name->getValue();
106 
107  $ending = substr($zip_name, -4);
108  if ($ending != ".zip") {
109  $zip_name .= ".zip";
110  $this->logger->info("Add .zip extension");
111  }
112 
113  //Download_name->getValue should return the complete path to the file
114  //Zip name is just an string
115  \ilFileDelivery::deliverFileAttached($download_name->getValue(), $zip_name);
116 
117  return new ThunkValue();
118  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
$path
Definition: ltiservices.php:32
global $DIC
Definition: feed.php:28
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::$logger = null
private

Definition at line 39 of file DownloadAllZipInteraction.php.

◆ OPTION_CANCEL

const ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::OPTION_CANCEL = 'cancel'

Definition at line 37 of file DownloadAllZipInteraction.php.

◆ OPTION_DOWNLOAD

const ILIAS\MediaCast\BackgroundTasks\DownloadAllZipInteraction::OPTION_DOWNLOAD = 'download'

Definition at line 36 of file DownloadAllZipInteraction.php.


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