/**
* @param Container $container
* @param array $callbacks [optional]
*/
public function __construct(Container $container, $callbacks = [])
{
$this->container = $container;
/** @var $httpRequest Request */
$request = $container->getService("httpRequest");
// Determine production/development mode
$this->active = !Debugger::$productionMode;
// # Clean cache
$this->callbacks["cache"] = ['name' => "Clear cache", 'callback' => Callback::closure($this, "clearCache"), 'args' => [[Cache::ALL => TRUE]]];
// # Clean session
$this->callbacks["session"] = ['name' => "Clear session", 'callback' => Callback::closure($this, "clearSession"), 'args' => []];
// # Clean logs
$this->callbacks["logs"] = ['name' => "Clear logs", 'callback' => Callback::closure($this, "clearLogs"), 'args' => [[Cache::ALL => TRUE]]];
// Merge custom callbacks
$this->callbacks = array_merge($this->callbacks, $callbacks);
// Check signal receiver
if ($this->active && ($cb = $request->getQuery("callback-do", FALSE))) {
if ($cb === "all") {
$this->onCallbacksCall();
$this->invokeCallbacks();
} else {
$this->onCallbackCall($cb);
$this->invokeCallback($cb);
}
}
}