ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilStaticMethodCallActivity.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 require_once './Services/WorkflowEngine/interfaces/ilActivity.php';
7 require_once './Services/WorkflowEngine/interfaces/ilNode.php';
8 
21 {
23  private $context;
24 
26  private $include_file = '';
27 
34  private $class_and_method_name = '';
35 
37  private $parameters;
38 
40  private $outputs;
41 
43  protected $name;
44 
50  public function __construct(ilNode $context)
51  {
52  $this->context = $context;
53  }
54 
64  public function setIncludeFilename($filename)
65  {
66  $this->include_file = $filename;
67  }
68 
74  public function getIncludeFilename()
75  {
76  return $this->include_file;
77  }
78 
79  /***
80  * Sets the class- and methodname of the method to be called.
81  * E.g. ilPonyStable::getPony
82  *
83  * @see $method_name
84  *
85  * @param string $name Classname::Methodname.
86  *
87  * @return void
88  */
89  public function setClassAndMethodName($name)
90  {
91  $this->class_and_method_name = $name;
92  }
93 
99  public function getClassAndMethodName()
100  {
102  }
103 
112  public function setParameters($params)
113  {
114  $this->parameters = $params;
115  }
116 
122  public function getParameters()
123  {
124  return $this->parameters;
125  }
126 
130  public function getOutputs()
131  {
132  return $this->outputs;
133  }
134 
138  public function setOutputs($outputs)
139  {
140  $this->outputs = $outputs;
141  }
142 
150  public function execute()
151  {
153  require_once './' . $this->include_file;
154  $name = explode('::', $this->class_and_method_name);
155 
156  $list = (array) $this->context->getContext()->getInstanceVars();
157  $params = array();
158  foreach ($this->parameters as $key => $parameter) {
159  $set = false;
160  foreach ($list as $instance_var) {
161  if ($instance_var['id'] == $parameter) {
162  $set = true;
163  $role = $instance_var['role'];
164  if ($instance_var['reference'] == true) {
165  foreach ($list as $definitions) {
166  if ($definitions['id'] == $instance_var['target']) {
167  $role = $definitions['role'];
168  }
169  }
170  }
171  $params[$role] = $this->context->getContext()->getInstanceVarById($parameter);
172  }
173  }
174  if (!$set) {
175  $params[$parameter] = $parameter;
176  $params[$key] = $parameter;
177  }
178  }
179 
181  $return_value = call_user_func_array(
182  array($name[0], $name[1]),
183  array($this, array($params, $this->outputs))
184  );
185  foreach ((array) $return_value as $key => $value) {
186  $this->context->getContext()->setInstanceVarById($key, $value);
187  }
188  }
189 
195  public function getContext()
196  {
197  return $this->context;
198  }
199 
203  public function setName($name)
204  {
205  $this->name = $name;
206  }
207 
211  public function getName()
212  {
213  return $this->name;
214  }
215 }
$params
Definition: disable.php:11
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
ilWorkflowEngineElement Interface is part of the petri net based workflow engine. ...
getClassAndMethodName()
Returns the currently set class- and methodname of the method to be called.
__construct(ilNode $context)
Default constructor.
getIncludeFilename()
Returns the currently set filename of the classfile to be included.
getParameters()
Returns the currently set parameters to be passed to the method.
PhpIncludeInspection
Definition: ilNode.php:25
Create styles array
The data for the language used.
setParameters($params)
Sets an array with params for the method.
ilActivity Interface is part of the petri net based workflow engine.
Definition: ilActivity.php:15
$key
Definition: croninfo.php:18
getContext()
Returns a reference to the parent node.
setIncludeFilename($filename)
Sets the name of the file to be included prior to calling the method.