ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilWorkflowDefinitionRepository Class Reference

Class ilWorkflowDefinitionRepository. More...

+ Collaboration diagram for ilWorkflowDefinitionRepository:

Public Member Functions

 __construct (\ilDBInterface $db, \ILIAS\Filesystem\Filesystems $fs, $path)
 ilWorkflowDefinitionRepository constructor. More...
 
 getAll ()
 
 has ($id)
 
 getById ($id)
 

Data Fields

const FILE_EXTENSTION_BPMN2 = 'bpmn2'
 
const FILE_EXTENSTION_PHP = 'php'
 
const FILE_PREFIX = 'wsd.il'
 

Protected Member Functions

 lazyLoadWorkflowDefinitions ()
 

Protected Attributes

 $db
 
 $fs
 
 $path
 
 $definitionsLoaded = false
 
 $definitions = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWorkflowDefinitionRepository::__construct ( \ilDBInterface  $db,
\ILIAS\Filesystem\Filesystems  $fs,
  $path 
)

ilWorkflowDefinitionRepository constructor.

Parameters
ilDBInterface$db
\ILIAS\Filesystem\Filesystems$fs
string$path

Definition at line 45 of file class.ilWorkflowDefinitionRepository.php.

References $db, $fs, and $path.

Member Function Documentation

◆ getAll()

ilWorkflowDefinitionRepository::getAll ( )
Returns
array

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

References $definitions, and lazyLoadWorkflowDefinitions().

+ Here is the call graph for this function:

◆ getById()

ilWorkflowDefinitionRepository::getById (   $id)
Parameters
string$id
Returns
array
Exceptions

ilWorkflowEngineException

Definition at line 140 of file class.ilWorkflowDefinitionRepository.php.

141 {
143 if (!$this->has($id)) {
144 throw new \ilWorkflowEngineException(sprintf("Could not find definition for id: %s", $id));
145 }
146
147 return $this->definitions[$id];
148 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, has(), and lazyLoadWorkflowDefinitions().

+ Here is the call graph for this function:

◆ has()

ilWorkflowDefinitionRepository::has (   $id)
Parameters
string$id
Returns
bool

Definition at line 129 of file class.ilWorkflowDefinitionRepository.php.

130 {
132 return isset($this->definitions[$id]);
133 }

References $id, and lazyLoadWorkflowDefinitions().

Referenced by getById().

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

◆ lazyLoadWorkflowDefinitions()

ilWorkflowDefinitionRepository::lazyLoadWorkflowDefinitions ( )
protected

Definition at line 55 of file class.ilWorkflowDefinitionRepository.php.

56 {
57 if ($this->definitionsLoaded) {
58 return;
59 }
60 $this->definitionsLoaded = true;
61
62 $query = 'SELECT workflow_class, COUNT(workflow_id) total, SUM(active) active
63 FROM wfe_workflows
64 GROUP BY workflow_class';
65 $result = $this->db->query($query);
66
67 $stats = array();
68 while ($row = $this->db->fetchAssoc($result)) {
69 $stats[$row['workflow_class']] = array('total' => $row['total'], 'active' => $row['active']);
70 }
71
72 if (!$this->fs->storage()->hasDir($this->path)) {
73 $this->definitions = array();
74 return;
75 }
76
77 $contents = $this->fs->storage()->listContents($this->path, false);
78 $contents = array_filter($contents, function (ILIAS\Filesystem\DTO\Metadata $file) {
79 if (!$file->isFile()) {
80 return false;
81 }
82
83 $fileParts = pathinfo($file->getPath());
84
85 return $fileParts['extension'] === self::FILE_EXTENSTION_BPMN2;
86 });
87
88 $prefixLength = strlen(self::FILE_PREFIX);
89
90 $definitions = [];
91 foreach ($contents as $file) {
92 $fileParts = pathinfo($file->getPath());
93 $extensionLength = strlen($fileParts['extension']) + 1;
94
95 $definition = [];
96
97 $definition['file'] = $fileParts['basename'];
98 $definition['id'] = $fileParts['filename'];
99
100 $parts = explode('_', substr($fileParts['basename'], $prefixLength, $extensionLength * -1));
101
102 $definition['status'] = 1;
103 if (!$this->fs->storage()->has($this->path . '/' . $definition['id'] . '.php')) {
104 $definition['status'] = 0;
105 }
106 $definition['version'] = substr(array_pop($parts), 1);
107 $definition['title'] = implode(' ', $parts);
108 $definition['instances'] = $stats[$definition['id'] . '.php'];
109
110 $definitions[$definition['id']] = $definition;
111 }
112
113 $this->definitions = $definitions;
114 }
$result
$row
Class FlySystemFileAccessTest.
Class BaseForm.
$query

References $definitions, $query, $result, $row, and Sabre\VObject\$stats.

Referenced by getAll(), getById(), and has().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilWorkflowDefinitionRepository::$db
protected

Definition at line 17 of file class.ilWorkflowDefinitionRepository.php.

Referenced by __construct().

◆ $definitions

ilWorkflowDefinitionRepository::$definitions = []
protected

Definition at line 37 of file class.ilWorkflowDefinitionRepository.php.

Referenced by getAll(), and lazyLoadWorkflowDefinitions().

◆ $definitionsLoaded

ilWorkflowDefinitionRepository::$definitionsLoaded = false
protected

Definition at line 32 of file class.ilWorkflowDefinitionRepository.php.

◆ $fs

ilWorkflowDefinitionRepository::$fs
protected

Definition at line 22 of file class.ilWorkflowDefinitionRepository.php.

Referenced by __construct().

◆ $path

ilWorkflowDefinitionRepository::$path
protected

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

Referenced by __construct().

◆ FILE_EXTENSTION_BPMN2

const ilWorkflowDefinitionRepository::FILE_EXTENSTION_BPMN2 = 'bpmn2'

Definition at line 9 of file class.ilWorkflowDefinitionRepository.php.

◆ FILE_EXTENSTION_PHP

const ilWorkflowDefinitionRepository::FILE_EXTENSTION_PHP = 'php'

Definition at line 10 of file class.ilWorkflowDefinitionRepository.php.

◆ FILE_PREFIX

const ilWorkflowDefinitionRepository::FILE_PREFIX = 'wsd.il'

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


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