Created
May 18, 2011 14:33
-
-
Save pragmaticivan/978689 to your computer and use it in GitHub Desktop.
Possibilidade de array no only e except para as before actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Executa os métodos adicionados no before e after action. | |
* | |
* @param array $methods | |
* @return void | |
*/ | |
private function execute_methods($methods) { | |
foreach ($methods as $key => $value) { | |
if (is_array($value)) { | |
if (isset($value['only'])) { | |
if (is_array($value['only'])) { | |
foreach ($value['only'] as $only) { | |
if ($this->request->action_name === $only) { | |
call_user_func(array($this,$key)); | |
} | |
} | |
} else { | |
if ($this->request->action_name === $value['only']) { | |
call_user_func(array($this,$key)); | |
} | |
} | |
} elseif(isset($value['except'])) { | |
if (is_array($value['except'])) { | |
foreach ($value['except'] as $except) { | |
if ($this->request->action_name !== $except) { | |
call_user_func(array($this,$key)); | |
} | |
} | |
} else { | |
if ($this->request->action_name !== $value['except']) { | |
call_user_func(array($this,$key)); | |
} | |
} | |
} | |
} else { | |
call_user_func(array($this,$value)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment