ILIAS  release_7 Revision v7.30-3-g800a261c036
ilFileObjectToStorageDirectory Class Reference

Class ilFileObjectToStorageDirectory. More...

+ Collaboration diagram for ilFileObjectToStorageDirectory:

Public Member Functions

 __construct (int $object_id, string $path)
 ilFileObjectToStorageDirectory constructor. More...
 
 getVersions ()
 
 getObjectId ()
 
 tearDown ()
 

Protected Attributes

 $object_id
 
 $path
 
 $versions = []
 

Private Member Functions

 initVersions ()
 
 getHistoryData ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileObjectToStorageDirectory::__construct ( int  $object_id,
string  $path 
)

ilFileObjectToStorageDirectory constructor.

Parameters
int$object_id
string$path

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

References $object_id, $path, and initVersions().

+ Here is the call graph for this function:

Member Function Documentation

◆ getHistoryData()

ilFileObjectToStorageDirectory::getHistoryData ( )
private
Returns
array

Definition at line 84 of file class.ilFileObjectToStorageDirectory.php.

84 : array
85 {
86 $info = ilHistory::_getEntriesForObject($this->object_id, 'file');
87 $history_data = [];
88 foreach ($info as $i) {
90 $version = (int) $parsed_info['version'];
91 $history_data[$version] = $parsed_info;
92 $history_data[$version]['owner_id'] = (int) $i['user_id'];
93 $history_data[$version]['date'] = (string) $i['date'];
94 $history_data[$version]['action'] = (string) $i['action'];
95 }
96
97 uasort($history_data, static function ($v1, $v2) {
98 return (int) $v2["version"] - (int) $v1["version"];
99 });
100 return $history_data;
101 }
static _getEntriesForObject($a_obj_id, $a_obj_type="")
get all history entries for an object
static parseInfoParams($entry)
Parses the info parameters ("info_params") of the specified history entry.
$i
Definition: metadata.php:24

References $i, ilHistory\_getEntriesForObject(), and ilObjFileImplementationLegacy\parseInfoParams().

Referenced by initVersions().

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

◆ getObjectId()

ilFileObjectToStorageDirectory::getObjectId ( )
Returns
int

Definition at line 114 of file class.ilFileObjectToStorageDirectory.php.

114 : int
115 {
116 return $this->object_id;
117 }

References $object_id.

Referenced by ilFileObjectToStorageMigrationRunner\migrate().

+ Here is the caller graph for this function:

◆ getVersions()

ilFileObjectToStorageDirectory::getVersions ( )
Returns
Generator|ilFileObjectToStorageVersion[]

Definition at line 106 of file class.ilFileObjectToStorageDirectory.php.

106 : Generator
107 {
108 yield from $this->versions;
109 }

References $versions.

Referenced by ilFileObjectToStorageMigrationRunner\migrate().

+ Here is the caller graph for this function:

◆ initVersions()

ilFileObjectToStorageDirectory::initVersions ( )
private

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

34 : void
35 {
36 $history_data = $this->getHistoryData();
37 try {
38 $g = new RegexIterator(
39 new RecursiveIteratorIterator(
40 new RecursiveDirectoryIterator(
41 $this->path,
42 FilesystemIterator::KEY_AS_PATHNAME
43 |FilesystemIterator::CURRENT_AS_FILEINFO
44 |FilesystemIterator::SKIP_DOTS
45 ),
46 RecursiveIteratorIterator::LEAVES_ONLY
47 ),
48 '/.*\/file_[\d]*\/([\d]*)\/(.*)/',
49 RegexIterator::GET_MATCH
50 );
51 } catch (Throwable $t) {
52 // there was an error reading the directory, there will be no versions
53 $g = [];
54 }
55
56
57 $this->versions = [];
58
59 foreach ($g as $item) {
60 $version = (int) $item[1];
61 $title = $history_data[$version]['filename'] ?? $item[2];
62 $action = $history_data[$version]['action'] ?? 'create';
63 $owner = $history_data[$version]['owner_id'] ?? 13;
64 $creation_date_timestamp = strtotime($history_data[$version]['date'] ?? '0');
65 if ($creation_date_timestamp === false) {
66 $creation_date_timestamp = 0;
67 }
68 $this->versions[$version] = new ilFileObjectToStorageVersion(
69 $version,
70 $item[0],
71 $title,
72 $title,
73 $action,
74 $creation_date_timestamp,
75 $owner
76 );
77 }
78 ksort($this->versions);
79 }
Class ilFileObjectToStorageVersion.

References getHistoryData().

Referenced by __construct().

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

◆ tearDown()

ilFileObjectToStorageDirectory::tearDown ( )

Definition at line 119 of file class.ilFileObjectToStorageDirectory.php.

119 : void
120 {
121 if (is_writable($this->path)) {
122 touch(rtrim($this->path, "/") . "/" . ilFileObjectToStorageMigrationHelper::MIGRATED);
123 }
124 }

References ilFileObjectToStorageMigrationHelper\MIGRATED.

Referenced by ilFileObjectToStorageMigrationRunner\migrate().

+ Here is the caller graph for this function:

Field Documentation

◆ $object_id

ilFileObjectToStorageDirectory::$object_id
protected

Definition at line 12 of file class.ilFileObjectToStorageDirectory.php.

Referenced by __construct(), and getObjectId().

◆ $path

ilFileObjectToStorageDirectory::$path
protected

Definition at line 16 of file class.ilFileObjectToStorageDirectory.php.

Referenced by __construct().

◆ $versions

ilFileObjectToStorageDirectory::$versions = []
protected

Definition at line 20 of file class.ilFileObjectToStorageDirectory.php.

Referenced by getVersions().


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