Skip to content

Instantly share code, notes, and snippets.

@matej21
Created March 16, 2016 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matej21/8a489139d3b676053a90 to your computer and use it in GitHub Desktop.
Save matej21/8a489139d3b676053a90 to your computer and use it in GitHub Desktop.
<?php
protected function tryCall($method, array $params)
{
$type = substr($method, 0, 6);
if ($type === 'action') {
$this->evm->dispatchEvent(get_class($this) . '::onBeforeAction', new EventArgsList([$this, $this->action]));
} elseif ($type === 'render') {
$this->evm->dispatchEvent(get_class($this) . '::onBeforeRender', new EventArgsList([$this, $this->view]));
}
$result = parent::tryCall($method, $params);
if ($type === 'action') {
$this->evm->dispatchEvent(get_class($this) . '::onAfterAction', new EventArgsList([$this, $this->action]));
} elseif ($type === 'render') {
$this->evm->dispatchEvent(get_class($this) . '::onAfterRender', new EventArgsList([$this, $this->view]));
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment