From f10650baa74f757b0eb20903ca62b22fdc6b53f3 Mon Sep 17 00:00:00 2001 From: Kristen Pol Date: Sat, 2 Dec 2023 18:09:19 +1100 Subject: [PATCH] Added special logic for showing redirect metadata view. --- .../views.view.quant_metadata_redirect.yml | 2 +- quant.links.task.yml | 2 +- quant.routing.yml | 8 +++ src/Page/QuantRedirectMetadata.php | 56 +++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 src/Page/QuantRedirectMetadata.php diff --git a/config/optional/views.view.quant_metadata_redirect.yml b/config/optional/views.view.quant_metadata_redirect.yml index 369a3474..e67a7051 100644 --- a/config/optional/views.view.quant_metadata_redirect.yml +++ b/config/optional/views.view.quant_metadata_redirect.yml @@ -655,7 +655,7 @@ display: position: 1 display_options: display_extenders: { } - path: admin/config/quant/metadata/redirect + path: admin/config/quant/metadata/redirectview cache_metadata: max-age: -1 contexts: diff --git a/quant.links.task.yml b/quant.links.task.yml index 5531e8d8..8afa5f8d 100644 --- a/quant.links.task.yml +++ b/quant.links.task.yml @@ -42,7 +42,7 @@ quant.metadata_file: weight: 30 quant.metadata_redirect: - route_name: view.quant_metadata_redirect.quant_metadata_redirect_page + route_name: quant.metadata_redirect title: 'Redirect Metadata' parent_id: quant.metadata weight: 40 diff --git a/quant.routing.yml b/quant.routing.yml index cce57ac5..612ba7d3 100644 --- a/quant.routing.yml +++ b/quant.routing.yml @@ -22,6 +22,14 @@ quant.metadata: requirements: _permission: 'configure quant' +quant.metadata_redirect: + path: '/admin/config/quant/metadata/redirect' + defaults: + _controller: '\Drupal\quant\Page\QuantRedirectMetadata::build' + _title: 'Redirect Metadata' + requirements: + _permission: 'configure quant' + quant.queue: path: '/admin/config/quant/queue-info' defaults: diff --git a/src/Page/QuantRedirectMetadata.php b/src/Page/QuantRedirectMetadata.php new file mode 100644 index 00000000..074d142c --- /dev/null +++ b/src/Page/QuantRedirectMetadata.php @@ -0,0 +1,56 @@ +moduleExists('redirect')) { + $message = $this->t('The redirect module is not enabled.'); + } + // Check view is found. + else { + $view = Views::getView('quant_metadata_redirect'); + if (!$view) { + $message = $this->t('The redirect metadata view was not found.'); + } + } + + // Show message. + if (!empty($message)) { + $build['info'] = [ + '#type' => 'markup', + '#markup' => $message, + ]; + return $build; + } + + // Render the view display. + //$output = views_embed_view('quant_metadata_redirect', 'quant_metadata_redirect_page'); + $view->setDisplay('quant_metadata_redirect_page'); + $view->preExecute(); + $view->execute(); + + return $view->buildRenderable(); + } + +}