|
@@ -12,6 +12,7 @@ trait Events
|
|
|
* @var array
|
|
* @var array
|
|
|
*/
|
|
*/
|
|
|
protected $_listeners = [
|
|
protected $_listeners = [
|
|
|
|
|
+ 'creating' => [],
|
|
|
'editing' => [],
|
|
'editing' => [],
|
|
|
'submitted' => [],
|
|
'submitted' => [],
|
|
|
'saving' => [],
|
|
'saving' => [],
|
|
@@ -20,6 +21,18 @@ trait Events
|
|
|
'deleted' => [],
|
|
'deleted' => [],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Set after getting creating model callback.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param Closure $callback
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return void
|
|
|
|
|
+ */
|
|
|
|
|
+ public function creating(Closure $callback)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_listeners['creating'][] = $callback;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Set after getting editing model callback.
|
|
* Set after getting editing model callback.
|
|
|
*
|
|
*
|
|
@@ -88,6 +101,16 @@ trait Events
|
|
|
$this->_listeners['deleted'][] = $callback;
|
|
$this->_listeners['deleted'][] = $callback;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Call creating callbacks.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return mixed
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function callCreating()
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->callListeners('creating');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Call editing callbacks.
|
|
* Call editing callbacks.
|
|
|
*
|
|
*
|