diff --git a/gulliver/system/class.xmlformTemplate.php b/gulliver/system/class.xmlformTemplate.php index 4337ec002..8b75f3af4 100644 --- a/gulliver/system/class.xmlformTemplate.php +++ b/gulliver/system/class.xmlformTemplate.php @@ -1,4 +1,7 @@ fetch ( 'mem:defaultTemplate' . $form->name ); + $output = AppEvent::getAppEvent() + ->setHtml($output) + ->dispatch(AppEvent::XMLFORM_RENDER, $form) + ->getHtml(); return $output; } diff --git a/workflow/engine/src/ProcessMaker/Core/AppEvent.php b/workflow/engine/src/ProcessMaker/Core/AppEvent.php new file mode 100644 index 000000000..40e983945 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Core/AppEvent.php @@ -0,0 +1,96 @@ +callbacks as $callback) { + $callback($type, $object, $this); + } + return $this; + } + + /** + * Add a closure function. + * + * @param function $callback + * @return $this + */ + public function addEvent($callback) + { + if (is_callable($callback)) { + $this->callbacks[] = $callback; + } + return $this; + } + + /** + * Get html value. + * + * @return string + */ + public function getHtml() + { + return $this->html; + } + + /** + * Set html value. + * + * @param string $html + * @return $this + */ + public function setHtml($html) + { + $this->html = $html; + return $this; + } +} diff --git a/workflow/public_html/app.php b/workflow/public_html/app.php index 9aa35b0ba..0ed5cffe2 100644 --- a/workflow/public_html/app.php +++ b/workflow/public_html/app.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Http\Kernel; use Maveriks\WebApplication; use Maveriks\Http\Response; use Maveriks\Pattern\Mvc\PhtmlView; +use ProcessMaker\Core\AppEvent; use ProcessMaker\Exception\RBACException; // Because laravel has a __ helper function, it's important we include the class.g file to ensure our __ is used. @@ -11,6 +12,7 @@ require_once __DIR__ . '/../../gulliver/system/class.g.php'; require_once __DIR__ . '/../../bootstrap/autoload.php'; require_once __DIR__ . '/../../bootstrap/app.php'; +AppEvent::getAppEvent(); register_shutdown_function( create_function(