Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezmoduleoperationinfo.php
Go to the documentation of this file.
1 <?php
17 class eZModuleOperationInfo
18 {
19 public $OperationList;
20 const ERROR_NO_CLASS = 5;
21 const ERROR_NO_CLASS_METHOD = 6;
22 const ERROR_CLASS_INSTANTIATE_FAILED = 7;
23 const ERROR_MISSING_PARAMETER = 8;
24
25 const STATUS_CONTINUE = 1;
26 const STATUS_CANCELLED = 2;
27 const STATUS_HALTED = 3;
28 const STATUS_REPEAT = 4;
29 const STATUS_QUEUED = 5;
30
37 public function __construct( $moduleName, $useTriggers = true )
38 {
39 $this->ModuleName = $moduleName;
40 $this->IsValid = false;
41 $this->OperationList = array();
42 $this->Memento = null;
43 $this->UseTriggers = $useTriggers;
44 }
45
51 function isValid()
52 {
53 return $this->IsValid;
54 }
55
60 function loadDefinition()
61 {
62 $pathList = eZModule::globalPathList();
63 foreach ( $pathList as $path )
64 {
65 $definitionFile = $path . '/' . $this->ModuleName . '/operation_definition.php';
66 if ( file_exists( $definitionFile ) )
67 break;
68 $definitionFile = null;
69 }
70 if ( $definitionFile === null )
71 {
72 eZDebug::writeError( 'Missing operation definition file for module: ' . $this->ModuleName, __METHOD__ );
73 return false;
74 }
75 unset( $OperationList );
76 include( $definitionFile );
77 if ( !isset( $OperationList ) )
78 {
79 eZDebug::writeError( 'Missing operation definition list for module: ' . $this->ModuleName, __METHOD__ );
80 return false;
81 }
82 $this->OperationList = $OperationList;
83 $this->IsValid = true;
84 return true;
85 }
86
87 function makeOperationKeyArray( $operationDefinition, $operationParameters )
88 {
89 $keyDefinition = null;
90 if ( array_key_exists( 'keys', $operationDefinition ) and
91 is_array( $operationDefinition['keys'] ) )
92 {
93 $keyDefinition = $operationDefinition['keys'];
94 }
95 return $this->makeKeyArray( $keyDefinition, $operationDefinition['parameters'], $operationParameters );
96 }
97
98 function makeKeyArray( $keyDefinition, $parameterDefinition, $operationParameters )
99 {
100 $keyArray = array();
101 if ( $keyDefinition !== null )
102 {
103 foreach ( $keyDefinition as $key )
104 {
105 $keyArray[$key] = $operationParameters[$key];
106 }
107 }
108 else
109 {
110 foreach ( $parameterDefinition as $operationParameter )
111 {
112 $keyArray[$operationParameter['name']] = $operationParameters[$operationParameter['name']];
113 }
114 }
115 return $keyArray;
116 }
117
126 function execute( $operationName, $operationParameters, $mementoData = null )
127 {
128 $moduleName = $this->ModuleName;
129 if ( !isset( $this->OperationList[$operationName] ) )
130 {
131 eZDebug::writeError( "No such operation '$operationName' in module '$moduleName'", __METHOD__ );
132 return null;
133 }
134 $operationDefinition = $this->OperationList[$operationName];
135 if ( !isset( $operationDefinition['default_call_method'] ) )
136 {
137 eZDebug::writeError( "No call method defined for operation '$operationName' in module '$moduleName'", __METHOD__ );
138 return null;
139 }
140 if ( !isset( $operationDefinition['body'] ) )
141 {
142 eZDebug::writeError( "No body for operation '$operationName' in module '$moduleName'", __METHOD__ );
143 return null;
144 }
145 if ( !isset( $operationDefinition['parameters'] ) )
146 {
147 eZDebug::writeError( "No parameters defined for operation '$operationName' in module '$moduleName'", __METHOD__ );
148 return null;
149 }
150 $callMethod = $operationDefinition['default_call_method'];
151 $resultArray = null;
152 $this->Memento = null;
153 if ( isset( $callMethod['include_file'] ) and
154 isset( $callMethod['class'] ) )
155 {
156 $bodyCallCount = array( 'loop_run' => array() );
157 $operationKeys = null;
158 if ( isset( $operationDefinition['keys'] ) )
159 $operationKeys = $operationDefinition['keys'];
160 $operationParameterDefinitions = $operationDefinition['parameters'];
161
162 $this->storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $operationName );
163
164 // Method callback that must be invoked when the operation gets interrupted (trigger, method...)
165 $onInterrupt = isset( $operationDefinition['on-interrupt'] ) ? $operationDefinition['on-interrupt'] : null;
166 $runOperation = true;
167 if ( $mementoData === null )
168 {
169 $keyArray = $this->makeOperationKeyArray( $operationDefinition, $operationParameters );
170 $mainMemento = null;
171 if ( $this->UseTriggers )
172 $mainMemento = eZOperationMemento::fetchMain( $keyArray );
173
174 if ( $mainMemento !== null )
175 {
176 $this->Memento = $mainMemento;
177 $mementoOperationData = $this->Memento->data();
178 if ( isset( $mementoOperationData['loop_run'] ) )
179 $bodyCallCount['loop_run'] = $mementoOperationData['loop_run'];
180 }
181
182
183 $mementoList = null;
184 if ( $this->UseTriggers )
185 $mementoList = eZOperationMemento::fetchList( $keyArray );
186
187 if ( count( $mementoList ) > 0 )
188 {
189 $lastResultArray = array();
190 $mementoRestoreSuccess = true;
191 // restoring running operation
192 foreach ( $mementoList as $memento )
193 {
194 $mementoData = $memento->data();
195 $memento->remove();
196
197 $resultArray = $this->executeBody( $callMethod['include_file'], $callMethod['class'], $operationDefinition['body'],
198 $operationKeys, $operationParameterDefinitions, $operationParameters,
199 $mementoData, $bodyCallCount, $operationDefinition['name'], null, $onInterrupt );
200 if ( is_array( $resultArray ) )
201 {
202 $lastResultArray = array_merge( $lastResultArray, $resultArray );
203 if ( !$resultArray['status'] )
204 $mementoRestoreSuccess = false;
205 }
206 }
207 $resultArray = $lastResultArray;
208 // $resultArray['status'] = $mementoRestoreSuccess;
209 $runOperation = false;
210 }
211 }
212 if ( $runOperation )
213 {
214 // start new operation
215 $resultArray = $this->executeBody( $callMethod['include_file'], $callMethod['class'], $operationDefinition['body'],
216 $operationKeys, $operationParameterDefinitions, $operationParameters,
217 $mementoData, $bodyCallCount, $operationDefinition['name'],
218 null, $onInterrupt );
219 }
220
221 if ( is_array( $resultArray ) and
222 isset( $resultArray['status'] ) and
223 ( $resultArray['status'] == eZModuleOperationInfo::STATUS_HALTED
224 or $resultArray['status'] == eZModuleOperationInfo::STATUS_REPEAT ) )
225 {
226 if ( $this->Memento !== null )
227 {
228 // $bodyCallCount stores an indexed array of each operation method that was executed
229 // it must be store in the memento on HALT/REPEAT so that the operation can be resumed
230 // where it was stopped (same behaviour as triggers)
231 $this->storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $operationName );
232 $data = $this->Memento->data();
233 $data['loop_run'] = $bodyCallCount['loop_run'];
234 $this->Memento->setData( $data );
235 $this->Memento->store();
236 }
237 }
238 else if ( $this->Memento !== null and
239 $this->Memento->attribute( 'id' ) !== null )
240 {
241 // eZDebug::writeDebug( $this->Memento, 'ezmodule operation result not halted' );
242 $this->Memento->remove();
243 }
244 // if ( $resultArray['status'] == eZModuleOperationInfo::STATUS_CANCELLED )
245 // {
246 // return null;
247 // }
248 /*
249 else if ( isset( $mementoData['memento_key'] ) )
250 {
251 $memento = eZOperationMemento::fetch( $mementoData['mementoKey'] );
252 if ( $memento->attribute( 'main_key') != $mementoData['mementoKey'] )
253 {
254 $mainMemento = eZOperationMemento::fetch( $memento->attribute( 'main_key') );
255 }
256 $memento->remove();
257 }
258 */
259 $this->Memento = null;
260 }
261 else
262 {
263 eZDebug::writeError( "No valid call methods found for operation '$operationName' in module '$moduleName'", __METHOD__ );
264 return null;
265 }
266 if ( !is_array( $resultArray ) )
267 {
268 eZDebug::writeError( "Operation '$operationName' in module '$moduleName' did not return a result array", __METHOD__ );
269 return null;
270 }
271 if ( isset( $resultArray['internal_error'] ) )
272 {
273 switch ( $resultArray['internal_error'] )
274 {
275 case eZModuleOperationInfo::ERROR_NO_CLASS:
276 {
277 $className = $resultArray['internal_error_class_name'];
278 eZDebug::writeError( "No class '$className' available for operation '$operationName' in module '$moduleName'", __METHOD__ );
279 return null;
280 } break;
281 case eZModuleOperationInfo::ERROR_NO_CLASS_METHOD:
282 {
283 $className = $resultArray['internal_error_class_name'];
284 $classMethodName = $resultArray['internal_error_class_method_name'];
285 eZDebug::writeError( "No method '$classMethodName' in class '$className' available for operation '$operationName' in module '$moduleName'", __METHOD__ );
286 return null;
287 } break;
288 case eZModuleOperationInfo::ERROR_CLASS_INSTANTIATE_FAILED:
289 {
290 $className = $resultArray['internal_error_class_name'];
291 eZDebug::writeError( "Failed instantiating class '$className' which is needed for operation '$operationName' in module '$moduleName'", __METHOD__ );
292 return null;
293 } break;
294 case eZModuleOperationInfo::ERROR_MISSING_PARAMETER:
295 {
296 $parameterName = $resultArray['internal_error_parameter_name'];
297 eZDebug::writeError( "Missing parameter '$parameterName' for operation '$operationName' in module '$moduleName'", __METHOD__ );
298 return null;
299 } break;
300 default:
301 {
302 $internalError = $resultArray['internal_error'];
303 eZDebug::writeError( "Unknown internal error '$internalError' for operation '$operationName' in module '$moduleName'", __METHOD__ );
304 return null;
305 } break;
306 }
307 return null;
308 }
309 else if ( isset( $resultArray['error'] ) )
310 {
311 }
312 else if ( isset( $resultArray['status'] ) )
313 {
314 return $resultArray;
315 }
316 else
317 {
318 eZDebug::writeError( "Operation '$operationName' in module '$moduleName' did not return a result value", __METHOD__ );
319 }
320 return null;
321 }
322
339 function executeBody( $includeFile, $className, $bodyStructure,
340 $operationKeys, $operationParameterDefinitions, $operationParameters,
341 &$mementoData, &$bodyCallCount, $operationName, $currentLoopData = null, $onInterrupt = null )
342 {
343 $bodyReturnValue = array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE );
344 $interrupt = false;
345 foreach ( $bodyStructure as $body )
346 {
347 if ( !isset( $body['type'] ) )
348 {
349 eZDebug::writeError( 'No type for body element, skipping', __METHOD__ );
350 continue;
351 }
352 if ( !isset( $body['name'] ) )
353 {
354 eZDebug::writeError( 'No name for body element, skipping', __METHOD__ );
355 continue;
356 }
357 $bodyName = $body['name'];
358 if ( !isset( $bodyCallCount['loop_run'][$bodyName] ) )
359 $bodyCallCount['loop_run'][$bodyName] = 0;
360 $type = $body['type'];
361 switch ( $type )
362 {
363 case 'loop':
364 {
365 $children = $body['children'];
366 $tmpOperationParameterDefinitions = $operationParameterDefinitions;
367 if ( isset( $body['child_parameters'] ) )
368 $tmpOperationParameterDefinitions = $body['child_parameters'];
369 $loopName = $body['name'];
370
371 if ( $mementoData !== null )
372 {
373 $returnValue = $this->executeBody( $includeFile, $className, $children,
374 $operationKeys, $tmpOperationParameterDefinitions, $operationParameters,
375 $mementoData, $bodyCallCount, $operationName, null );
376 if ( !$returnValue['status'] )
377 return $returnValue;
378 }
379 else
380 {
381 ++$bodyCallCount['loop_run'][$bodyName];
382
383 $method = $body['method'];
384 $resultArray = $this->executeClassMethod( $includeFile, $className, $method,
385 $operationParameterDefinitions, $operationParameters );
386 $parameters = array();
387 if ( isset( $resultArray['parameters'] ) )
388 {
389 $parameters = $resultArray['parameters'];
390 }
391 $count = 0;
392 $countDone = 0;
393 $countHalted = 0;
394 $countCanceled = 0;
395 $countRepeated = 0;
396 foreach ( $parameters as $parameterStructure )
397 {
398 $tmpOperationParameters = $operationParameters;
399 foreach ( $parameterStructure as $parameterName => $parameterValue )
400 {
401 $tmpOperationParameters[$parameterName] = $parameterValue;
402 }
403
404 ++$count;
405 $returnValue = $this->executeBody( $includeFile, $className, $children,
406 $operationKeys, $tmpOperationParameterDefinitions, $tmpOperationParameters,
407 $mementoData, $bodyCallCount, $operationName, array( 'name' => $loopName,
408 'count' => count( $parameters ),
409 'index' => $count ) );
410 switch( $returnValue['status'] )
411 {
412 case eZModuleOperationInfo::STATUS_CANCELLED:
413 {
414 $bodyReturnValue = $returnValue;
415 ++$countCanceled;
416 }break;
417 case eZModuleOperationInfo::STATUS_CONTINUE:
418 {
419 $bodyReturnValue = $returnValue;
420
421 ++$countDone;
422 }break;
423 case eZModuleOperationInfo::STATUS_HALTED:
424 {
425 $bodyReturnValue = $returnValue;
426 ++$countHalted;
427 }break;
428 case eZModuleOperationInfo::STATUS_REPEAT:
429 {
430 $bodyReturnValue = $returnValue;
431 ++$countRepeated;
432 }break;
433 }
434 }
435 if ( $body['continue_operation'] == 'all' )
436 {
437 if ( $count == $countDone )
438 {
439 // continue operation
440 }
441 if ( $countCanceled > 0 )
442 {
443 return $bodyReturnValue;
444 //cancel operation
445 }
446 if ( $countHalted > 0 )
447 {
448 return $bodyReturnValue; //show tempalate
449 }
450
451 }
452 }
453 } break;
454 case 'trigger':
455 {
456 if ( !$this->UseTriggers )
457 {
458 $bodyReturnValue['status'] = eZModuleOperationInfo::STATUS_CONTINUE;
459 continue 2;
460 }
461
462 $triggerName = $body['name'];
463 $triggerRestored = false;
464 $executeTrigger = true;
465 if ( $mementoData !== null )
466 {
467 if ( $mementoData['name'] == $triggerName )
468 {
469 $executeTrigger = $this->restoreBodyMementoData( $bodyName, $mementoData,
470 $operationParameters, $bodyCallCount, $currentLoopData );
471 $triggerRestored = true;
472 }
473 else
474 {
475 $executeTrigger = false;
476 }
477 }
478 $interrupt = false;
479 if ( $executeTrigger )
480 {
481 $status = $this->executeTrigger( $bodyReturnValue, $body,
482 $operationParameterDefinitions, $operationParameters,
483 $bodyCallCount, $currentLoopData,
484 $triggerRestored, $operationName, $operationKeys );
485
486 switch( $status )
487 {
488 case eZModuleOperationInfo::STATUS_CONTINUE:
489 {
490 $bodyReturnValue['status'] = eZModuleOperationInfo::STATUS_CONTINUE;
491 }break;
492 case eZModuleOperationInfo::STATUS_CANCELLED:
493 {
494 $bodyReturnValue['status'] = eZModuleOperationInfo::STATUS_CANCELLED;
495 $interrupt = true;
496 }break;
497 case eZModuleOperationInfo::STATUS_HALTED:
498 {
499
500 $bodyReturnValue['status'] = eZModuleOperationInfo::STATUS_HALTED;
501 $interrupt = true;
502 }break;
503 case eZModuleOperationInfo::STATUS_REPEAT:
504 {
505
506 $bodyReturnValue['status'] = eZModuleOperationInfo::STATUS_REPEAT;
507 $interrupt = true;
508 }
509 }
510 }else
511 {
512 $bodyReturnValue['status'] = eZModuleOperationInfo::STATUS_CONTINUE;
513 }
514 } break;
515 case 'method':
516 {
517 if ( $mementoData === null )
518 {
519 $method = $body['method'];
520 $frequency = $body['frequency'];
521 $executeMethod = true;
522 if ( $frequency == 'once' and
523 $bodyCallCount['loop_run'][$bodyName] != 0 )
524 $executeMethod = false;
525 $tmpOperationParameterDefinitions = $operationParameterDefinitions;
526 if ( isset( $body['parameters'] ) )
527 $tmpOperationParameterDefinitions = $body['parameters'];
528 if ( $executeMethod )
529 {
530 $result = $this->executeClassMethod( $includeFile, $className, $method,
531 $tmpOperationParameterDefinitions, $operationParameters );
532 if ( $result && array_key_exists( 'status', $result ) )
533 {
534 switch( $result['status'] )
535 {
536 case eZModuleOperationInfo::STATUS_CONTINUE:
537 default:
538 {
539 // moved from outside the case:
540 // we don't want to count the method as executed if it doesn't return a CONTINUE status,
541 // or it won't be executed next run
542 ++$bodyCallCount['loop_run'][$bodyName];
543 $result['status'] = eZModuleOperationInfo::STATUS_CONTINUE;
544 $bodyReturnValue = $result;
545 } break;
546
547 case eZModuleOperationInfo::STATUS_CANCELLED:
548 case eZModuleOperationInfo::STATUS_HALTED:
549 {
550 $bodyReturnValue = $result;
551 $interrupt = true;
552 } break;
553 }
554 }
555 }
556 }
557 } break;
558 default:
559 {
560 eZDebug::writeError( "Unknown operation type $type", __METHOD__ );
561 }
562 }
563
564 if ( $interrupt )
565 {
566 // If the operation defined an interrupt callback, we execute it before returning
567 if ( $onInterrupt )
568 {
569 $this->executeClassMethod(
570 $includeFile,
571 $className,
572 $onInterrupt['method'],
573 ( isset( $onInterrupt['parameters'] ) ? $onInterrupt['parameters'] : array() ),
574 $operationParameters
575 );
576 }
577 return $bodyReturnValue;
578 }
579 }
580
581 return $bodyReturnValue;
582 }
583
598 function executeTrigger( &$bodyReturnValue, $body,
599 $operationParameterDefinitions, $operationParameters,
600 &$bodyCallCount, $currentLoopData,
601 $triggerRestored, $operationName, &$operationKeys )
602 {
603 $triggerName = $body['name'];
604 $triggerKeys = $body['keys'];
605
606 $status = eZTrigger::runTrigger( $triggerName, $this->ModuleName, $operationName, $operationParameters, $triggerKeys );
607
608
609 if ( $status['Status'] == eZTrigger::WORKFLOW_DONE ||
610 $status['Status'] == eZTrigger::NO_CONNECTED_WORKFLOWS )
611 {
612 ++$bodyCallCount['loop_run'][$triggerName];
613 return eZModuleOperationInfo::STATUS_CONTINUE;
614 }
615 else if ( $status['Status'] == eZTrigger::STATUS_CRON_JOB ||
616 $status['Status'] == eZTrigger::FETCH_TEMPLATE ||
617 $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT ||
618 $status['Status'] == eZTrigger::REDIRECT )
619 {
620 $bodyMemento = $this->storeBodyMemento( $triggerName, $triggerKeys,
621 $operationKeys, $operationParameterDefinitions, $operationParameters,
622 $bodyCallCount, $currentLoopData, $operationName );
623 $workflowProcess = $status['WorkflowProcess'];
624 if ( $workflowProcess !== null )
625 {
626 $workflowProcess->setAttribute( 'memento_key', $bodyMemento->attribute( 'memento_key' ) );
627 $workflowProcess->store();
628 }
629
630 $bodyReturnValue['result'] = $status['Result'];
631 if ( $status['Status'] == eZTrigger::REDIRECT )
632 {
633 $bodyReturnValue['redirect_url'] = $status['Result'];
634 }
635 if ( $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT )
636 {
637 // Hack for project issue #14371 (fetch template repeat)
638 // The object version's status is set to REPEAT so that it can
639 // be submitted again
640 if ( $operationName == 'publish' && $this->ModuleName == 'content' )
641 {
642 eZContentOperationCollection::setVersionStatus( $operationParameters['object_id'],
643 $operationParameters['version'], eZContentObjectVersion::STATUS_REPEAT );
644 }
645 return eZModuleOperationInfo::STATUS_REPEAT;
646 }
647 else
648 {
649 return eZModuleOperationInfo::STATUS_HALTED;
650 }
651 }
652 else if ( $status['Status'] == eZTrigger::WORKFLOW_CANCELLED or
653 $status['Status'] == eZTrigger::WORKFLOW_RESET )
654 {
655 return eZModuleOperationInfo::STATUS_CANCELLED;
656 $bodyReturnValue['result'] = $status['Result'];
657 }
658 }
659
660 function storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters,
661 &$bodyCallCount, $operationName )
662 {
663 $mementoData = array();
664 $mementoData['module_name'] = $this->ModuleName;
665 $mementoData['operation_name'] = $operationName;
666 if ( $this->Memento === null )
667 {
668 $keyArray = $this->makeKeyArray( $operationKeys, $operationParameterDefinitions, $operationParameters );
669 $mementoData['loop_run'] = $bodyCallCount['loop_run'];
670 $memento = eZOperationMemento::create( $keyArray, $mementoData, true );
671 $this->Memento = $memento;
672 }
673 else
674 {
675 $mementoData = $this->Memento->data();
676 $mementoData['loop_run'] = $bodyCallCount['loop_run'];
677 $this->Memento->setData( $mementoData );
678 }
679 }
680
681 function removeBodyMemento( $bodyName, $bodyKeys,
682 $operationKeys, $operationParameterDefinitions, $operationParameters,
683 &$bodyCallCount, $currentLoopData, $operationName )
684 {
685 $keyArray = $this->makeKeyArray( $operationKeys, $operationParameterDefinitions, $operationParameters );
686 }
687
701 function storeBodyMemento( $bodyName, $bodyKeys,
702 $operationKeys, $operationParameterDefinitions, $operationParameters,
703 &$bodyCallCount, $currentLoopData, $operationName )
704 {
705 $this->storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $operationName );
706
707 $keyArray = $this->makeKeyArray( $operationKeys, $operationParameterDefinitions, $operationParameters );
708 $http = eZHTTPTool::instance();
709 $keyArray['session_key'] = $http->sessionID();
710 $mementoData = array();
711 $mementoData['name'] = $bodyName;
712 $mementoData['parameters'] = $operationParameters;
713 $mementoData['loop_data'] = $currentLoopData;
714 $mementoData['module_name'] = $this->ModuleName;
715 $mementoData['operation_name'] = $operationName;
716 $memento = eZOperationMemento::create( $keyArray, $mementoData, false, $this->Memento->attribute( 'memento_key' ) );
717 $memento->store();
718 return $memento;
719 }
720
721 function restoreBodyMementoData( $bodyName, &$mementoData,
722 &$operationParameters, &$bodyCallCount, &$currentLoopData )
723 {
724 $operationParameters = array();
725 if ( isset( $mementoData['parameters'] ) )
726 $operationParameters = $mementoData['parameters'];
727 if ( isset( $mementoData[ 'main_memento' ] ) )
728 {
729 $this->Memento = $mementoData[ 'main_memento' ];
730 $mainMementoData = $this->Memento->data();
731 if ( isset( $mainMementoData['loop_run'] ) )
732 {
733 $bodyCallCount['loop_run'] = $mainMementoData['loop_run'];
734 }
735
736 }
737
738 // if ( $this->Memento !== null )
739 // {
740 // $mementoOperationData = $this->Memento->data();
741 // if ( isset( $mementoOperationData['loop_run'] ) )
742 // $bodyCallCount['loop_run'] = $mementoOperationData['loop_run'];
743 // }
744 if ( isset( $mementoData['loop_data'] ) )
745 $currentLoopData = $mementoData['loop_data'];
746
747 if ( isset( $mementoData['skip_trigger'] ) && $mementoData['skip_trigger'] == true )
748 {
749 $mementoData = null;
750 return false;
751 }
752 else
753 {
754 $mementoData = null;
755 return true;
756 }
757
758 return true;
759 }
760
771 function executeClassMethod( $includeFile, $className, $methodName,
772 $operationParameterDefinitions, $operationParameters )
773 {
774 if ( !class_exists( $className ) )
775 {
776 include_once( $includeFile );
777
778 if ( !class_exists( $className, false ) )
779 {
780 return array( 'internal_error' => eZModuleOperationInfo::ERROR_NO_CLASS,
781 'internal_error_class_name' => $className );
782 }
783 }
784 $classObject = $this->objectForClass( $className );
785 if ( $classObject === null )
786 {
787 return array( 'internal_error' => eZModuleOperationInfo::ERROR_CLASS_INSTANTIATE_FAILED,
788 'internal_error_class_name' => $className );
789 }
790 if ( !method_exists( $classObject, $methodName ) )
791 {
792 return array( 'internal_error' => eZModuleOperationInfo::ERROR_NO_CLASS_METHOD,
793 'internal_error_class_name' => $className,
794 'internal_error_class_method_name' => $methodName );
795 }
796 $parameterArray = array();
797
798 foreach ( $operationParameterDefinitions as $operationParameterDefinition )
799 {
800 $parameterName = $operationParameterDefinition['name'];
801 if ( isset( $operationParameterDefinition['constant'] ) )
802 {
803 $constantValue = $operationParameterDefinition['constant'];
804 $parameterArray[] = $constantValue;
805 }
806 else if ( isset( $operationParameters[$parameterName] ) )
807 {
808 // Do type checking
809 $parameterArray[] = $operationParameters[$parameterName];
810 }
811 else
812 {
813 if ( $operationParameterDefinition['required'] )
814 {
815
816 return array( 'internal_error' => eZModuleOperationInfo::ERROR_MISSING_PARAMETER,
817 'internal_error_parameter_name' => $parameterName );
818 }
819 else if ( isset( $operationParameterDefinition['default'] ) )
820 {
821 $parameterArray[] = $operationParameterDefinition['default'];
822 }
823 else
824 {
825 $parameterArray[] = null;
826 }
827 }
828 }
829
830 return call_user_func_array( array( $classObject, $methodName ), $parameterArray );
831 }
832
840 function objectForClass( $className )
841 {
842 if ( !isset( $GLOBALS['eZModuleOperationClassObjectList'] ) )
843 {
844 $GLOBALS['eZModuleOperationClassObjectList'] = array();
845 }
846 if ( isset( $GLOBALS['eZModuleOperationClassObjectList'][$className] ) )
847 {
848 return $GLOBALS['eZModuleOperationClassObjectList'][$className];
849 }
850
851 return $GLOBALS['eZModuleOperationClassObjectList'][$className] = new $className();
852 }
853
855 public $ModuleName;
856 public $FunctionList;
857 public $IsValid;
858 public $UseTriggers = false;
859
863 public $Memento;
864 }
865
866 ?>
eZContentObjectVersion\STATUS_REPEAT
const STATUS_REPEAT
Definition: ezcontentobjectversion.php:36
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZHTTPTool\instance
static instance()
Definition: ezhttptool.php:189
eZModuleOperationInfo
The class eZModuleOperationInfo does.
Definition: ezmoduleoperationinfo.php:18
eZModuleOperationInfo\$Memento
$Memento
Definition: ezmoduleoperationinfo.php:863
eZModuleOperationInfo\$UseTriggers
$UseTriggers
Definition: ezmoduleoperationinfo.php:858
eZModuleOperationInfo\storeBodyMemento
storeBodyMemento( $bodyName, $bodyKeys, $operationKeys, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $currentLoopData, $operationName)
Definition: ezmoduleoperationinfo.php:701
eZModuleOperationInfo\storeOperationMemento
storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $operationName)
Definition: ezmoduleoperationinfo.php:660
eZModuleOperationInfo\STATUS_HALTED
const STATUS_HALTED
Definition: ezmoduleoperationinfo.php:27
eZModuleOperationInfo\executeClassMethod
executeClassMethod( $includeFile, $className, $methodName, $operationParameterDefinitions, $operationParameters)
Definition: ezmoduleoperationinfo.php:771
eZModuleOperationInfo\$IsValid
$IsValid
Definition: ezmoduleoperationinfo.php:857
eZModuleOperationInfo\STATUS_CANCELLED
const STATUS_CANCELLED
Definition: ezmoduleoperationinfo.php:26
eZModuleOperationInfo\STATUS_REPEAT
const STATUS_REPEAT
Definition: ezmoduleoperationinfo.php:28
eZModuleOperationInfo\removeBodyMemento
removeBodyMemento( $bodyName, $bodyKeys, $operationKeys, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $currentLoopData, $operationName)
Definition: ezmoduleoperationinfo.php:681
eZModuleOperationInfo\STATUS_QUEUED
const STATUS_QUEUED
Definition: ezmoduleoperationinfo.php:29
eZModuleOperationInfo\$ModuleName
$ModuleName
Definition: ezmoduleoperationinfo.php:855
eZModuleOperationInfo\objectForClass
objectForClass( $className)
Definition: ezmoduleoperationinfo.php:840
eZModuleOperationInfo\__construct
__construct( $moduleName, $useTriggers=true)
Definition: ezmoduleoperationinfo.php:37
eZModuleOperationInfo\executeTrigger
executeTrigger(&$bodyReturnValue, $body, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $currentLoopData, $triggerRestored, $operationName, &$operationKeys)
Definition: ezmoduleoperationinfo.php:598
eZModuleOperationInfo\ERROR_NO_CLASS
const ERROR_NO_CLASS
Definition: ezmoduleoperationinfo.php:20
eZModuleOperationInfo\ERROR_CLASS_INSTANTIATE_FAILED
const ERROR_CLASS_INSTANTIATE_FAILED
Definition: ezmoduleoperationinfo.php:22
eZModuleOperationInfo\$OperationList
$OperationList
Definition: ezmoduleoperationinfo.php:19
eZModuleOperationInfo\ERROR_NO_CLASS_METHOD
const ERROR_NO_CLASS_METHOD
Definition: ezmoduleoperationinfo.php:21
eZModuleOperationInfo\ERROR_MISSING_PARAMETER
const ERROR_MISSING_PARAMETER
Definition: ezmoduleoperationinfo.php:23
eZModuleOperationInfo\isValid
isValid()
Definition: ezmoduleoperationinfo.php:51
eZModuleOperationInfo\loadDefinition
loadDefinition()
Definition: ezmoduleoperationinfo.php:60
eZModuleOperationInfo\restoreBodyMementoData
restoreBodyMementoData( $bodyName, &$mementoData, &$operationParameters, &$bodyCallCount, &$currentLoopData)
Definition: ezmoduleoperationinfo.php:721
eZModuleOperationInfo\STATUS_CONTINUE
const STATUS_CONTINUE
Definition: ezmoduleoperationinfo.php:25
eZModuleOperationInfo\$FunctionList
$FunctionList
Definition: ezmoduleoperationinfo.php:856
eZModuleOperationInfo\makeOperationKeyArray
makeOperationKeyArray( $operationDefinition, $operationParameters)
Definition: ezmoduleoperationinfo.php:87
eZModuleOperationInfo\makeKeyArray
makeKeyArray( $keyDefinition, $parameterDefinition, $operationParameters)
Definition: ezmoduleoperationinfo.php:98
eZModuleOperationInfo\execute
execute( $operationName, $operationParameters, $mementoData=null)
Definition: ezmoduleoperationinfo.php:126
eZModuleOperationInfo\executeBody
executeBody( $includeFile, $className, $bodyStructure, $operationKeys, $operationParameterDefinitions, $operationParameters, &$mementoData, &$bodyCallCount, $operationName, $currentLoopData=null, $onInterrupt=null)
Definition: ezmoduleoperationinfo.php:339
eZModule\globalPathList
static globalPathList()
Definition: ezmodule.php:1881
eZOperationMemento\fetchList
static fetchList( $mementoKey, $asObject=true)
Definition: ezoperationmemento.php:103
eZOperationMemento\create
static create( $mementoKey, $data=array(), $isMainKey=false, $mainKey=null)
Definition: ezoperationmemento.php:129
eZOperationMemento\fetchMain
static fetchMain( $mementoKey, $asObject=true)
Definition: ezoperationmemento.php:89
eZTrigger\WORKFLOW_RESET
const WORKFLOW_RESET
Definition: eztrigger.php:24
eZTrigger\WORKFLOW_DONE
const WORKFLOW_DONE
Definition: eztrigger.php:19
eZTrigger\NO_CONNECTED_WORKFLOWS
const NO_CONNECTED_WORKFLOWS
Definition: eztrigger.php:21
eZTrigger\FETCH_TEMPLATE
const FETCH_TEMPLATE
Definition: eztrigger.php:22
eZTrigger\STATUS_CRON_JOB
const STATUS_CRON_JOB
Definition: eztrigger.php:18
eZTrigger\REDIRECT
const REDIRECT
Definition: eztrigger.php:23
eZTrigger\FETCH_TEMPLATE_REPEAT
const FETCH_TEMPLATE_REPEAT
Definition: eztrigger.php:25
eZTrigger\WORKFLOW_CANCELLED
const WORKFLOW_CANCELLED
Definition: eztrigger.php:20
eZTrigger\runTrigger
static runTrigger( $name, $moduleName, $function, $parameters, $keys=null)
Definition: eztrigger.php:125
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.