-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added special logic for showing redirect metadata view.
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Drupal\quant\Page; | ||
|
||
use Drupal\Core\Controller\ControllerBase; | ||
use Drupal\views\Views; | ||
|
||
/** | ||
* Page controller for the redirect metadata page. | ||
*/ | ||
class QuantRedirectMetadata extends ControllerBase { | ||
|
||
/** | ||
* Page callback for the redirect metadata page. | ||
* | ||
* If the redirect module is enabled and the metadata view exists, then show | ||
* the view. Otherwise, show a help message. | ||
* | ||
* @return array | ||
* A render array. | ||
*/ | ||
public function build() { | ||
|
||
$view = NULL; | ||
$message = ''; | ||
// Check module is installed. | ||
if (!\Drupal::moduleHandler()->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(); | ||
} | ||
|
||
} |