ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilStyleIRSSMigration Class Reference
+ Inheritance diagram for ilStyleIRSSMigration:
+ Collaboration diagram for ilStyleIRSSMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 
 getFileNameCallback (string $pattern)
 
 getRevisionNameCallback ()
 

Protected Member Functions

 buildBasePath (int $object_id)
 

Protected Attributes

ilResourceStorageMigrationHelper $helper
 

Private Member Functions

 recursiveRmDir (string $path)
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Detailed Description

Definition at line 25 of file class.ilStyleIRSSMigration.php.

Member Function Documentation

◆ buildBasePath()

ilStyleIRSSMigration::buildBasePath ( int  $object_id)
protected

Definition at line 107 of file class.ilStyleIRSSMigration.php.

References CLIENT_WEB_DIR.

Referenced by step().

107  : string
108  {
109  return CLIENT_WEB_DIR . '/sty/sty_' . $object_id;
110  }
const CLIENT_WEB_DIR
Definition: constants.php:47
+ Here is the caller graph for this function:

◆ getDefaultAmountOfStepsPerRun()

ilStyleIRSSMigration::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

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

34  : int
35  {
36  return 10000;
37  }

◆ getFileNameCallback()

ilStyleIRSSMigration::getFileNameCallback ( string  $pattern)

Definition at line 112 of file class.ilStyleIRSSMigration.php.

112  : Closure
113  {
114  return static function (string $file_name) use ($pattern): string {
115  if (preg_match($pattern, $file_name, $matches)) {
116  return $matches[1] ?? $file_name;
117  }
118  return $file_name;
119  };
120  }

◆ getLabel()

ilStyleIRSSMigration::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 29 of file class.ilStyleIRSSMigration.php.

29  : string
30  {
31  return 'Migration of style images to the resource storage service.';
32  }

◆ getPreconditions()

ilStyleIRSSMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 39 of file class.ilStyleIRSSMigration.php.

References ilResourceStorageMigrationHelper\getPreconditions().

+ Here is the call graph for this function:

◆ getRemainingAmountOfSteps()

ilStyleIRSSMigration::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 97 of file class.ilStyleIRSSMigration.php.

References Vendor\Package\$d, and $r.

97  : int
98  {
99  $r = $this->helper->getDatabase()->query(
100  "SELECT COUNT(id) AS amount FROM style_data WHERE rid IS NULL OR rid = ''"
101  );
102  $d = $this->helper->getDatabase()->fetchObject($r) ?? new stdClass();
103 
104  return (int) ($d->amount ?? 0);
105  }
$r

◆ getRevisionNameCallback()

ilStyleIRSSMigration::getRevisionNameCallback ( )

Definition at line 122 of file class.ilStyleIRSSMigration.php.

122  : Closure
123  {
124  return static function (string $file_name): string {
125  return md5($file_name);
126  };
127  }

◆ prepare()

ilStyleIRSSMigration::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 44 of file class.ilStyleIRSSMigration.php.

44  : void
45  {
46  $this->helper = new ilResourceStorageMigrationHelper(
48  $environment
49  );
50  }

◆ recursiveRmDir()

ilStyleIRSSMigration::recursiveRmDir ( string  $path)
private

Definition at line 88 of file class.ilStyleIRSSMigration.php.

88  : void
89  {
90  // recursively remove directory
91  $files = array_diff(scandir($path), ['.', '..']);
92  foreach ($files as $file) {
93  (is_dir("$path/$file")) ? $this->recursiveRmDir("$path/$file") : unlink("$path/$file");
94  }
95  }
$path
Definition: ltiservices.php:29

◆ step()

ilStyleIRSSMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

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

References Vendor\Package\$d, $r, buildBasePath(), ILIAS\Repository\int(), and null.

52  : void
53  {
54  $r = $this->helper->getDatabase()->query(
55  "SELECT id FROM style_data WHERE rid IS NULL OR rid = '' LIMIT 1;"
56  );
57 
58  $d = $this->helper->getDatabase()->fetchObject($r);
59  $object_id = (int) ($d->id ?? null);
60 
61  $resource_owner_id = (int) ($d->owner_id ?? 6); // TODO JOIN
62 
63  $style_path = $this->buildBasePath($object_id);
64 
65  $rid = $this->helper->moveDirectoryToContainerResource(
66  $style_path,
67  $resource_owner_id
68  );
69 
70  if ($rid !== null) {
71  $this->helper->getDatabase()->update(
72  'style_data',
73  ['rid' => ['text', $rid->serialize()]],
74  ['id' => ['integer', $object_id],]
75  );
76 
77  //$this->recursiveRmDir($lm_path);
78  } else {
79  /*
80  $this->helper->getDatabase()->update(
81  'style_data',
82  ['rid' => ['text', '-']],
83  ['id' => ['integer', $object_id],]
84  );*/
85  }
86  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$r
+ Here is the call graph for this function:

Field Documentation

◆ $helper

ilResourceStorageMigrationHelper ilStyleIRSSMigration::$helper
protected

Definition at line 27 of file class.ilStyleIRSSMigration.php.


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