Skip to content

Commit

Permalink
renaming for clarity
Browse files Browse the repository at this point in the history
the `$key` variable is used as the numeric index placeholder for actions under the same `$trigger` key in `unregister()` and `removeAction()` while is been used as a placeholder for a trigger in `trigger(...)`.

every `$this->data[$trigger]` is an array of actions, so i believe it's clearer to use that name

renaming the argument `trigger($event, ...)` allows as to usde consistenty the name `$trigger` for event keys in `$this->data`
  • Loading branch information
maks feltrin committed Apr 30, 2016
1 parent 9e77c6d commit 13c61ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions upload/system/engine/event.php
Expand Up @@ -36,11 +36,11 @@ public function removeAction($trigger, $route) {
}
}

public function trigger($trigger, $args = array()) {
foreach ($this->data as $key => $value) {
if (preg_match('/^' . str_replace(array('\*', '\?'), array('.*', '.'), preg_quote($key, '/')) . '/', $trigger)) {
foreach ($value as $event) {
$result = $event->execute($this->registry, $args);
public function trigger($event, $args = array()) {
foreach ($this->data as $trigger => $actions) {
if (preg_match('/^' . str_replace(array('\*', '\?'), array('.*', '.'), preg_quote($trigger, '/')) . '/', $event)) {
foreach ($actions as $action) {
$result = $action->execute($this->registry, $args);

if (!is_null($result) && !($result instanceof Exception)) {
return $result;
Expand Down

0 comments on commit 13c61ba

Please sign in to comment.