/**
  * {@inheritdoc}
  */
 public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL)
 {
     if ($route_name === '<current>') {
         if ($current_route = $this->routeMatch->getRouteObject()) {
             $requirements = $current_route->getRequirements();
             // Setting _method and _schema is deprecated since 2.7. Using
             // setMethods() and setSchemes() are now the recommended ways.
             unset($requirements['_method']);
             unset($requirements['_schema']);
             $route->setRequirements($requirements);
             $route->setPath($current_route->getPath());
             $route->setSchemes($current_route->getSchemes());
             $route->setMethods($current_route->getMethods());
             $route->setOptions($current_route->getOptions());
             $route->setDefaults($current_route->getDefaults());
             $parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
             if ($bubbleable_metadata) {
                 $bubbleable_metadata->addCacheContexts(['route']);
             }
         } else {
             // If we have no current route match available, point to the frontpage.
             $route->setPath('/');
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function applies(RouteMatchInterface $route_match)
 {
     if ($route_match->getRouteObject() !== null) {
         $URI = $route_match->getRouteObject()->getPath();
         // Use this theme on a certain route.
         return substr($URI, 1, 4) == 'view';
     }
 }
 /**
  * {@inheritdoc}
  */
 public function processOutbound($route_name, Route $route, array &$parameters)
 {
     if ($route_name === '<current>' && ($current_route = $this->routeMatch->getRouteObject())) {
         $route->setPath($current_route->getPath());
         $route->setRequirements($current_route->getRequirements());
         $route->setOptions($current_route->getOptions());
         $route->setDefaults($current_route->getDefaults());
         $parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
     }
 }
Beispiel #4
0
 /**
  * Determines whether the active route is an admin one.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   (optional) The route to determine whether it is an admin one. Per default
  *   this falls back to the route object on the active request.
  *
  * @return bool
  *   Returns TRUE if the route is an admin one, otherwise FALSE.
  */
 public function isAdminRoute(Route $route = NULL)
 {
     if (!$route) {
         $route = $this->routeMatch->getRouteObject();
         if (!$route) {
             return FALSE;
         }
     }
     return (bool) $route->getOption('_admin_route');
 }
 /**
  * {@inheritdoc}
  */
 public function processOutbound($route_name, Route $route, array &$parameters)
 {
     if ($route_name === '<current>') {
         if ($current_route = $this->routeMatch->getRouteObject()) {
             $route->setPath($current_route->getPath());
             $route->setRequirements($current_route->getRequirements());
             $route->setOptions($current_route->getOptions());
             $route->setDefaults($current_route->getDefaults());
             $parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
         } else {
             // If we have no current route match available, point to the frontpage.
             $route->setPath('/');
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function determineBlockContext()
 {
     if (($route_object = $this->routeMatch->getRouteObject()) && ($route_contexts = $route_object->getOption('parameters')) && isset($route_contexts['node'])) {
         $context = new Context(new ContextDefinition($route_contexts['node']['type']));
         if ($node = $this->routeMatch->getParameter('node')) {
             $context->setContextValue($node);
         }
         $this->addContext('node', $context);
     } elseif ($this->routeMatch->getRouteName() == 'node.add') {
         $node_type = $this->routeMatch->getParameter('node_type');
         $context = new Context(new ContextDefinition('entity:node'));
         $context->setContextValue(Node::create(array('type' => $node_type->id())));
         $this->addContext('node', $context);
     }
 }
 /**
  * @inheritdoc
  */
 public function applies(RouteMatchInterface $route_match)
 {
     if ($route_match->getRouteObject()) {
         return $route_match->getRouteName() == 'dmaps.locations.geocoder_options';
     }
     return FALSE;
 }
Beispiel #8
0
 /**
  * Handler a response for a given view and display.
  *
  * @param string $view_id
  *   The ID of the view
  * @param string $display_id
  *   The ID of the display.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  * @return null|void
  */
 public function handle($view_id, $display_id, RouteMatchInterface $route_match)
 {
     $args = array();
     $route = $route_match->getRouteObject();
     $map = $route->hasOption('_view_argument_map') ? $route->getOption('_view_argument_map') : array();
     foreach ($map as $attribute => $parameter_name) {
         // Allow parameters be pulled from the request.
         // The map stores the actual name of the parameter in the request. Views
         // which override existing controller, use for example 'node' instead of
         // arg_nid as name.
         if (isset($map[$attribute])) {
             $attribute = $map[$attribute];
         }
         if ($arg = $route_match->getRawParameter($attribute)) {
         } else {
             $arg = $route_match->getParameter($attribute);
         }
         if (isset($arg)) {
             $args[] = $arg;
         }
     }
     /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase $class */
     $class = $route->getOption('_view_display_plugin_class');
     if ($route->getOption('returns_response')) {
         /** @var \Drupal\views\Plugin\views\display\ResponseDisplayPluginInterface $class */
         return $class::buildResponse($view_id, $display_id, $args);
     } else {
         $build = $class::buildBasicRenderable($view_id, $display_id, $args, $route);
         Page::setPageRenderArray($build);
         return $build;
     }
 }
Beispiel #9
0
  /**
   * Displays add links for the available bundles.
   *
   * Redirects to the add form if there's only one bundle available.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
   *   The route match.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse|array
   *   If there's only one available bundle, a redirect response.
   *   Otherwise, a render array with the add links for each bundle.
   */
  public function addPage(RouteMatchInterface $routeMatch) {
    $routeName = $routeMatch->getRouteName();
    $defaults = $routeMatch->getRouteObject()->getDefaults();
    if (empty($defaults['_bundle_type'])) {
      throw new \InvalidArgumentException(sprintf('The route "%s" must have a "_bundle_type" default parameter.', $routeName));
    }

    $formRouteName = str_replace('.add_page', '.add_form', $routeName);
    $bundleType = $defaults['_bundle_type'];
    $bundles = $this->entityManager()->getStorage($bundleType)->loadMultiple();
    // Filter out the bundles the user doesn't have access to.
    $accessControlHandler = $this->entityManager()->getAccessControlHandler($bundleType);
    $bundles = array_filter($bundles, function($bundle) use ($accessControlHandler) {
      return $accessControlHandler->createAccess($bundle->id());
    });
    // Redirect if there's only one bundle available.
    if (count($bundles) == 1) {
      $bundle = reset($bundles);

      return $this->redirect($formRouteName, [$bundleType => $bundle->id()]);
    }

    return [
      '#theme' => 'commerce_add_list',
      '#bundles' => $bundles,
      '#bundle_type' => $bundleType,
      '#form_route_name' => $formRouteName,
    ];
  }
Beispiel #10
0
 /**
  * Loads entity browser object for this page.
  *
  * @return \Drupal\entity_browser\EntityBrowserInterface
  *   Loads the entity browser object
  */
 protected function loadBrowser()
 {
     /** @var $route \Symfony\Component\Routing\Route */
     $route = $this->currentRouteMatch->getRouteObject();
     /** @var $browser \Drupal\entity_browser\EntityBrowserInterface */
     return $this->browserStorage->load($route->getDefault('entity_browser_id'));
 }
Beispiel #11
0
 /**
  * {@inheritdoc}
  */
 public function getRuntimeContexts(array $unqualified_context_ids)
 {
     $result = [];
     $context = new Context(new ContextDefinition('entity:node', NULL, FALSE));
     if (($route_object = $this->routeMatch->getRouteObject()) && ($route_contexts = $route_object->getOption('parameters')) && isset($route_contexts['node'])) {
         if ($node = $this->routeMatch->getParameter('node')) {
             $context->setContextValue($node);
         }
     } elseif ($this->routeMatch->getRouteName() == 'node.add') {
         $node_type = $this->routeMatch->getParameter('node_type');
         $context->setContextValue(Node::create(array('type' => $node_type->id())));
     }
     $cacheability = new CacheableMetadata();
     $cacheability->setCacheContexts(['route']);
     $context->addCacheableDependency($cacheability);
     $result['node'] = $context;
     return $result;
 }
Beispiel #12
0
  /**
   * Constructs a new Entity Clone form.
   *
   * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The route match service.
   * @param \Drupal\Core\StringTranslation\TranslationManager $string_translation
   *   The string translation manager.
   *
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function __construct(EntityTypeManager $entity_type_manager, RouteMatchInterface $route_match, TranslationManager $string_translation) {
    $this->entityTypeManager = $entity_type_manager;
    $this->stringTranslationManager = $string_translation;

    $parameter_name = $route_match->getRouteObject()->getOption('_entity_clone_entity_type_id');
    $this->entity = $route_match->getParameter($parameter_name);

    $this->entityTypeDefinition = $entity_type_manager->getDefinition($this->entity->getEntityTypeId());
  }
Beispiel #13
0
 /**
  * Prints the loaded structure of the current entity.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *    A RouteMatch object.
  *
  * @return array
  *    Array of page elements to render.
  */
 public function entityTokens(RouteMatchInterface $route_match)
 {
     $output = [];
     $parameter_name = $route_match->getRouteObject()->getOption('_token_entity_type_id');
     $entity = $route_match->getParameter($parameter_name);
     if ($entity && $entity instanceof EntityInterface) {
         $output = $this->renderTokenTree($entity);
     }
     return $output;
 }
Beispiel #14
0
 /**
  * Build the view draft page.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route match.
  *
  * @return array
  *   Render array.
  *
  * @throws \Exception
  *   Thrown when the entity is not found in the given graph.
  */
 public function view(RouteMatchInterface $route_match)
 {
     $parameter_name = $route_match->getRouteObject()->getOption('entity_type_id');
     /** @var \Drupal\Core\Entity\EntityInterface $entity */
     $entity = $route_match->getParameter($parameter_name);
     $storage = $this->entityManager->getStorage($entity->getEntityTypeId());
     $graph_name = $route_match->getRouteObject()->getOption('graph_name');
     $storage->setRequestGraphs($entity->id(), [$graph_name]);
     $draft_entity = $storage->load($entity->id());
     if (!$draft_entity) {
         // Should not occur: RdfGraphAccessCheck validates that the entity exists.
         throw new \Exception('Entity not loaded from graph');
     }
     $page = $this->entityManager->getViewBuilder($entity->getEntityTypeId())->view($draft_entity, 'full');
     $page['#pre_render'][] = [$this, 'buildTitle'];
     $page['#entity_type'] = $entity->getEntityTypeId();
     $page['#' . $page['#entity_type']] = $draft_entity;
     return $page;
 }
 /**
  * {@inheritdoc}
  */
 public function processPlaceholders(array $placeholders)
 {
     // Routes can opt out from using the BigPipe HTML delivery technique.
     if ($this->routeMatch->getRouteObject()->getOption('_no_big_pipe')) {
         return [];
     }
     if (!$this->sessionConfiguration->hasSession($this->requestStack->getCurrentRequest())) {
         return [];
     }
     return $this->doProcessPlaceholders($placeholders);
 }
 /**
  * {@inheritdoc}
  */
 public function getRuntimeContexts(array $unqualified_context_ids)
 {
     $result = [];
     $context_definition = new ContextDefinition('entity:rdf_entity:asset_release', NULL, FALSE);
     $value = NULL;
     if (($route_object = $this->routeMatch->getRouteObject()) && ($route_contexts = $route_object->getOption('parameters')) && isset($route_contexts['rdf_entity'])) {
         /** @var \Drupal\rdf_entity\RdfInterface $asset_release */
         if ($asset_release = $this->routeMatch->getParameter('rdf_entity')) {
             if ($asset_release->bundle() == 'asset_release') {
                 $value = $asset_release;
             }
         }
     }
     $cacheability = new CacheableMetadata();
     $cacheability->setCacheContexts(['route']);
     $context = new Context($context_definition, $value);
     $context->addCacheableDependency($cacheability);
     $result['asset_release'] = $context;
     return $result;
 }
 /**
  * Prints the revision tree of the current entity.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *    A RouteMatch object.
  *
  * @return array
  *    Array of page elements to render.
  */
 public function revisions(RouteMatchInterface $route_match)
 {
     $output = array();
     $parameter_name = $route_match->getRouteObject()->getOption('_entity_type_id');
     $entity = $route_match->getParameter($parameter_name);
     if ($entity && $entity instanceof EntityInterface) {
         $tree = \Drupal::service('entity.index.rev.tree')->getTree($entity->uuid());
         $output = array('#theme' => 'item_list', '#attributes' => array('class' => array('multiversion')), '#attached' => array('library' => array('multiversion_ui/drupal.multiversion_ui.admin')), '#items' => $tree, '#list_type' => 'ul');
     }
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 protected function getFormArgument(RouteMatchInterface $route_match)
 {
     $form_arg = $route_match->getRouteObject()->getDefault('_entity_wizard');
     list($entity_type_id, $operation) = explode('.', $form_arg);
     $definition = $this->entityManager->getDefinition($entity_type_id);
     $handlers = $definition->getHandlerClasses();
     if (empty($handlers['wizard'][$operation])) {
         throw new \Exception(sprintf('Unsupported wizard operation %s', $operation));
     }
     return $handlers['wizard'][$operation];
 }
 /**
  * {@inheritdoc}
  */
 public function getRuntimeContexts(array $unqualified_context_ids)
 {
     $result = [];
     $context_definition = new ContextDefinition('entity:support_ticket', NULL, FALSE);
     $value = NULL;
     if (($route_object = $this->routeMatch->getRouteObject()) && ($route_contexts = $route_object->getOption('parameters')) && isset($route_contexts['support_ticket'])) {
         if ($support_ticket = $this->routeMatch->getParameter('support_ticket')) {
             $value = $support_ticket;
         }
     } elseif ($this->routeMatch->getRouteName() == 'support_ticket.add') {
         $support_ticket_type = $this->routeMatch->getParameter('support_ticket_type');
         $value = SupportTicket::create(array('type' => $support_ticket_type->id()));
     }
     $cacheability = new CacheableMetadata();
     $cacheability->setCacheContexts(['route']);
     $context = new Context($context_definition, $value);
     $context->addCacheableDependency($cacheability);
     $result['support_ticket'] = $context;
     return $result;
 }
Beispiel #20
0
 /**
  * {@inheritdoc}
  */
 public function applies(RouteMatchInterface $route_match)
 {
     if (!$this->state->get('system.maintenance_mode')) {
         return FALSE;
     }
     if ($route = $route_match->getRouteObject()) {
         if ($route->getOption('_maintenance_access')) {
             return FALSE;
         }
     }
     return TRUE;
 }
Beispiel #21
0
 /**
  * {@inheritdoc}
  */
 public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)
 {
     $json = [];
     $json['content'] = (string) $this->renderer->renderRoot($main_content);
     if (!empty($main_content['#title'])) {
         $json['title'] = (string) $main_content['#title'];
     } else {
         $json['title'] = (string) $this->titleResolver->getTitle($request, $route_match->getRouteObject());
     }
     $response = new CacheableJsonResponse($json, 200);
     $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($main_content));
     return $response;
 }
 /**
  * Checks access to the overview based on permissions and translatability.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The route_match to check against.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(RouteMatchInterface $route_match, AccountInterface $account)
 {
     $route = $route_match->getRouteObject();
     /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
     $mapper = $this->configMapperManager->createInstance($route->getDefault('plugin_id'));
     $mapper->populateFromRouteMatch($route_match);
     $this->sourceLanguage = $this->languageManager->getLanguage($mapper->getLangcode());
     // Allow access to the translation overview if the proper permission is
     // granted, the configuration has translatable pieces, and the source
     // language is not locked if it is present.
     $source_language_access = is_null($this->sourceLanguage) || !$this->sourceLanguage->isLocked();
     $access = $account->hasPermission('translate configuration') && $mapper->hasSchema() && $mapper->hasTranslatable() && $source_language_access;
     return AccessResult::allowedIf($access)->cachePerPermissions();
 }
 /**
  * {@inheritdoc}
  */
 public function getRuntimeContexts(array $unqualified_context_ids)
 {
     $result = [];
     $value = NULL;
     if (($route_object = $this->routeMatch->getRouteObject()) && ($route_contexts = $route_object->getOption('parameters')) && isset($route_contexts['rdf_entity'])) {
         /** @var \Drupal\rdf_entity\RdfInterface $collection */
         if ($collection = $this->routeMatch->getParameter('rdf_entity')) {
             if ($collection->bundle() == 'collection') {
                 $value = $collection;
             }
         }
     } elseif (($route_parameters = $this->routeMatch->getParameters()) && in_array($this->routeMatch->getRouteName(), $this->getSupportedRoutes())) {
         foreach ($route_parameters as $route_parameter) {
             if ($route_parameter instanceof ContentEntityInterface) {
                 $bundle = $route_parameter->bundle();
                 $entity_type = $route_parameter->getEntityTypeId();
                 // Check if the object is a og content entity.
                 if (Og::isGroupContent($entity_type, $bundle) && ($groups = $this->membershipManager->getGroupIds($route_parameter, 'rdf_entity', 'collection'))) {
                     // A content can belong to only one rdf_entity.
                     // Check that the content is not an orphaned one.
                     if ($collection_id = reset($groups['rdf_entity'])) {
                         $collection = Rdf::load($collection_id);
                         $value = $collection;
                     }
                 }
             }
         }
     }
     $cacheability = new CacheableMetadata();
     $cacheability->setCacheContexts(['route']);
     $collection_context_definition = new ContextDefinition('entity', $this->t('Organic group provided by collection'), FALSE);
     $context = new Context($collection_context_definition, $value);
     $context->addCacheableDependency($cacheability);
     $result['og'] = $context;
     return $result;
 }
Beispiel #24
0
 /**
  * {@inheritdoc}
  */
 public function processPlaceholders(array $placeholders)
 {
     $request = $this->requestStack->getCurrentRequest();
     // @todo remove this check when https://www.drupal.org/node/2367555 lands.
     if (!$request->isMethodSafe()) {
         return [];
     }
     // Routes can opt out from using the BigPipe HTML delivery technique.
     if ($this->routeMatch->getRouteObject()->getOption('_no_big_pipe')) {
         return [];
     }
     if (!$this->sessionConfiguration->hasSession($request)) {
         return [];
     }
     return $this->doProcessPlaceholders($placeholders);
 }
 /**
  * Lists all instances of fields on any views.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *    A RouteMatch object.
  *
  * @return array
  *   The Views fields report page.
  */
 public function entityMarkup(RouteMatchInterface $route_match)
 {
     $parameter_name = $route_match->getRouteObject()->getOption('_devel_entity_type_id');
     $entity = $route_match->getParameter($parameter_name);
     $entity_type_id = $entity->getEntityTypeId();
     $key = \Drupal::request()->get('key', 'default');
     $builded_entity = entity_view($entity, $key);
     $markup = \Drupal::service('renderer')->render($builded_entity);
     $links = array();
     $active_view_modes = \Drupal::service('entity_display.repository')->getViewModeOptionsByBundle($entity_type_id, $entity->bundle());
     foreach ($active_view_modes as $id => $label) {
         $links[] = array('title' => $label, 'url' => Url::fromRoute("entity.{$entity_type_id}.devel_markup", array($entity_type_id => $entity->id(), 'key' => $id)));
     }
     $build['links'] = array('#theme' => 'links', '#links' => $links, '#prefix' => '<hr/><div>', '#suffix' => '</div><hr />');
     $build['markup'] = ['#markup' => '<code><pre>' . Html::escape($markup) . '</pre></code>', '#cache' => array('max-age' => 0), '#allowed_tags' => ['code', 'pre']];
     return $build;
 }
Beispiel #26
0
 /**
  * {@inheritdoc}
  */
 public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)
 {
     $response = new AjaxResponse();
     // First render the main content, because it might provide a title.
     $content = $this->renderer->renderRoot($main_content);
     // Attach the library necessary for using the OpenOffCanvasDialogCommand and
     // set the attachments for this Ajax response.
     $main_content['#attached']['library'][] = 'outside_in/drupal.off_canvas';
     $response->setAttachments($main_content['#attached']);
     // If the main content doesn't provide a title, use the title resolver.
     $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject());
     // Determine the title: use the title provided by the main content if any,
     // otherwise get it from the routing information.
     $options = $request->request->get('dialogOptions', []);
     $response->addCommand(new OpenOffCanvasDialogCommand($title, $content, $options));
     return $response;
 }
Beispiel #27
0
 /**
  * {@inheritdoc}
  */
 public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)
 {
     $response = new AjaxResponse();
     // First render the main content, because it might provide a title.
     $content = drupal_render_root($main_content);
     // Attach the library necessary for using the OpenDialogCommand and set the
     // attachments for this Ajax response.
     $main_content['#attached']['library'][] = 'core/drupal.dialog.ajax';
     $response->setAttachments($main_content['#attached']);
     // Determine the title: use the title provided by the main content if any,
     // otherwise get it from the routing information.
     $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject());
     // Determine the dialog options and the target for the OpenDialogCommand.
     $options = $request->request->get('dialogOptions', array());
     $target = $this->determineTargetSelector($options, $route_match);
     $response->addCommand(new OpenDialogCommand($target, $title, $content, $options));
     return $response;
 }
 /**
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *
  * @return \Drupal\Core\Entity\ContentEntityInterface
  *
  * @throws \Exception
  *   Thrown when no entity was found.
  */
 protected function extractEntityFromRouteMatch(RouteMatchInterface $route_match)
 {
     $route = $route_match->getRouteObject();
     $options = $route->getOptions();
     if (isset($options['parameters'])) {
         foreach ($options['parameters'] as $name => $details) {
             if (!empty($details['type']) && strpos($details['type'], 'entity_revision:') !== FALSE) {
                 return $route_match->getParameter($name);
             }
         }
         foreach ($options['parameters'] as $name => $details) {
             if (!empty($details['type']) && strpos($details['type'], 'entity:') !== FALSE) {
                 return $route_match->getParameter($name);
             }
         }
     }
     throw new \Exception('No entity found');
 }
 /**
  * {@inheritdoc}
  */
 public function getArgumentsResolver(RouteMatchInterface $route_match, AccountInterface $account, Request $request = NULL)
 {
     $route = $route_match->getRouteObject();
     // Defaults for the parameters defined on the route object need to be added
     // to the raw arguments.
     $raw_route_arguments = $route_match->getRawParameters()->all() + $route->getDefaults();
     $upcasted_route_arguments = $route_match->getParameters()->all();
     // Parameters which are not defined on the route object, but still are
     // essential for access checking are passed as wildcards to the argument
     // resolver. An access-check method with a parameter of type Route,
     // RouteMatchInterface, AccountInterface or Request will receive those
     // arguments regardless of the parameter name.
     $wildcard_arguments = [$route, $route_match, $account];
     if (isset($request)) {
         $wildcard_arguments[] = $request;
     }
     return new ArgumentsResolver($raw_route_arguments, $upcasted_route_arguments, $wildcard_arguments);
 }
 /**
  * Download callback for the exported RDF.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *    The RouteMatch object.
  * @param string $export_format
  *    The serialization format (e.g. turtle, rdfxml, ...).
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *    Response object with correct headers set.
  */
 public function download(RouteMatchInterface $route_match, $export_format)
 {
     $formats = $this->getSerializerFormats();
     if (!isset($formats[$export_format])) {
         throw new AccessDeniedHttpException();
     }
     $format = $formats[$export_format];
     $entity_type_id = $route_match->getRouteObject()->getOption('entity_type_id');
     $entity = $route_match->getParameter($entity_type_id);
     if (!$entity || !$entity instanceof EntityInterface) {
         throw new AccessDeniedHttpException();
     }
     $output = $this->serializeRdfEntity($entity->id(), $export_format);
     $response = new Response();
     $response->setContent($output);
     $response->headers->set('Content-Type', $format->getDefaultMimeType());
     $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'export.' . $format->getDefaultExtension());
     $response->headers->set('Content-Disposition', $disposition);
     return $response;
 }