Skip to content

Commit

Permalink
Small simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Jul 13, 2018
1 parent 005dcf0 commit 72f7bff
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/midcom/baseclasses/components/request.php
Expand Up @@ -345,13 +345,11 @@ public function can_handle(array $argv)
$this->_prepare_request_switch($routes);

foreach ($routes as $key => $request) {
if (!$this->_validate_route($request, $argv)) {
continue;
if ($this->_validate_route($request, $argv)) {
// Prepare the handler object
$this->_prepare_handler($key, $request, $argv);
return true;
}

// Prepare the handler object
$this->_prepare_handler($key, $request, $argv);
return true;
}
// No match
return false;
Expand All @@ -376,10 +374,6 @@ private function _prepare_request_switch(array &$routes)
if (!array_key_exists('variable_args', $value)) {
$value['variable_args'] = 0;
}

if (is_string($value['handler'])) {
$value['handler'] = [&$this, $value['handler']];
}
}
}

Expand Down Expand Up @@ -438,7 +432,10 @@ private function _prepare_handler($key, array $request, array $argv = [])
$request['id'] = $key;
$request['args'] = array_slice($argv, count($request['fixed_args']));

if (is_string($request['handler'][0])) {
if (is_string($request['handler'])) {
// Support for handlers in request class (deprecated)
$request['handler'] = [&$this, $request['handler']];
} elseif (is_string($request['handler'][0])) {
$classname = $request['handler'][0];
if (!class_exists($classname)) {
throw new midcom_error("Failed to create a class instance of the type {$classname}, the class is not declared.");
Expand Down

0 comments on commit 72f7bff

Please sign in to comment.