You are here

public static function TaskHandler::getType in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Utility/TaskHandler.php \Drupal\maestro\Utility\TaskHandler::getType()

Get the type of task handler.

2 calls to TaskHandler::getType()
MaestroTaskConsoleController::getTasks in modules/maestro_taskconsole/src/Controller/MaestroTaskConsoleController.php
GetTasks method This method is called by the menu router for /taskconsole. The output of this method is the current user's task console.
TaskHandler::getHandlerURL in src/Utility/TaskHandler.php
Get the handler's URL.

File

src/Utility/TaskHandler.php, line 20

Class

TaskHandler
Internal function that helps determine the handler type that is used for interactive tasks.

Namespace

Drupal\maestro\Utility

Code

public static function getType($handler) {
  global $base_url;
  $handler = str_replace($base_url, '', $handler);
  $handler_type = 'unknown';
  $is_externalRoute = UrlHelper::isExternal($handler);
  if ($is_externalRoute === FALSE) {
    try {
      if (function_exists($handler)) {
        $handler_type = 'function';
      }
      else {
        $url = Url::fromUri("internal:" . $handler);
        if ($url && $url
          ->isRouted()) {
          $handler_type = 'internal';
        }
      }
    } catch (\InvalidArgumentException $e) {
      $handler_type = 'unknown';
    }
  }
  else {
    $handler_type = 'external';
  }
  return $handler_type;
}