Skip to content
Snippets Groups Projects
Commit bf7ce0f9 authored by lu4nik's avatar lu4nik
Browse files

Port to Drupal 8

parent dc1b95e5
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @file
* Contains \Drupal\navigation404\Controller\Navigation404Controller.
*/
namespace Drupal\navigation404\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Provides route responses for navigation404.module.
*/
class Navigation404Controller extends ControllerBase {
/**
* Returns "Not found" text.
*/
public function notFound() {
return array(
'#markup' => $this->t('The requested page could not be found.')
);
}
}
name = "404 Navigation"
description = "On a 404 page, ensure navigation links are displayed properly."
core = 7.x
name: 404 Navigation
description: On a 404 page, ensure navigation links are displayed properly.
type: module
core: 8.x
<?php
/**
* Implements hook_enable().
* @file install file.
*/
/**
* Implements hook_install().
*
* If site_404 is not set, all menu-related items disappear on 404.
*/
function navigation404_enable() {
if (variable_get('site_404', '') == '') {
variable_set('site_404', NAVIGATION404_PAGE);
function navigation404_install() {
if (!Drupal::config('system.site')->get('page.404')) {
Drupal::config('system.site')->set('page.404', NAVIGATION404_PAGE)->save();
}
}
/**
* Implements hook_disable().
* Implements hook_uninstall().
*/
function navigation404_disable() {
if (variable_get('site_404', '') == NAVIGATION404_PAGE) {
variable_del('site_404');
function navigation404_uninstall() {
if (Drupal::config('system.site')->get('page.404') == NAVIGATION404_PAGE) {
Drupal::config('system.site')->delete('page.404');
}
}
<?php
define('NAVIGATION404_PAGE', 'navigation404');
/**
* Implements hook_menu().
* @file main module file.
*/
function navigation404_menu() {
$items[NAVIGATION404_PAGE] = array(
'title' => 'Page not found',
'access callback' => TRUE,
'page callback' => 'navigation404_404_page',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Our custom menu callback that returns Drupal's standard 404 message.
*/
function navigation404_404_page() {
drupal_set_title(t('Page not found'));
return t('The requested page could not be found.');
}
define('NAVIGATION404_PAGE', 'navigation404');
/**
* Implements hook_form_alter().
......
navigation404.content:
path: navigation404
defaults:
_content: '\Drupal\navigation404\Controller\Navigation404Controller::notFound'
_title: 'Page not found'
requirements:
_access: 'TRUE'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment