This commit is contained in:
Roly Rudy Gutierrez Pinto
2018-08-29 09:44:42 -04:00
parent 7b7afb14c0
commit 0e4dab49f0
3 changed files with 105 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
<?php
namespace ProcessMaker\Core;
class AppEvent
{
/**
* Identify XML Form type elements
*/
const XMLFORM_RENDER = 0;
/**
* Represents the AppEvent object.
*
* @var object
*/
private static $appEvent = null;
/**
* List of closure elements.
*
* @var array
*/
private $callbacks = [];
/**
* Represents the html string.
*
* @var string
*/
private $html = null;
/**
* Get an AppEvent object.
*
* @return object
*/
public static function getAppEvent()
{
if (self::$appEvent === null) {
self::$appEvent = new AppEvent();
}
return self::$appEvent;
}
/**
* Process all closure elements.
*
* @param int $type
* @param object $object
* @return $this
*/
public function dispatch($type, $object)
{
foreach ($this->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;
}
}

View File

@@ -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(