You are here

public static function CalendarHelper::getViewRouteParameters in Calendar 8

Parameters

array $args: The provided arguments.

\Drupal\views\ViewExecutable $view: The view.

Return value

array

2 calls to CalendarHelper::getViewRouteParameters()
CalendarHelper::getURLForGranularity in src/CalendarHelper.php
Get the Url object that will link to the view for the given granularity and arguments.
CalendarHelper::getViewsURL in src/CalendarHelper.php
Get the Url object to link to a View display with given arguments.

File

src/CalendarHelper.php, line 958

Class

CalendarHelper
Defines Gregorian Calendar date values.

Namespace

Drupal\calendar

Code

public static function getViewRouteParameters($args, ViewExecutable $view) {
  $route_parameters = [];
  $path = $view
    ->getPath();
  $views_arguments = $view->args;
  $bits = is_string($path) ? explode('/', $path) : false;
  $arg_counter = 0;
  if ($bits != false) {
    foreach ($bits as $pos => $bit) {
      if ($bit == '%') {

        // Generate the name of the parameter using the key of the argument
        // handler.
        $arg_id = 'arg_' . $arg_counter++;
        $route_parameters[$arg_id] = array_shift($views_arguments);
      }
      elseif (strpos($bit, '%') === 0) {

        // Use the name defined in the path.
        $parameter_name = substr($bit, 1);
        $route_parameters[$parameter_name] = array_shift($views_arguments);
        $arg_counter++;
      }
    }
  }
  for ($i = $arg_counter; $i < $i + count($args); $i++) {
    $route_parameters['arg_' . $i] = array_shift($args);
  }
  return $route_parameters;
}