Commit 6df1d3ad authored by alexpott's avatar alexpott

Issue #1979004 by plopesc: Convert tour_test_1() to a Controller.

parent a78b614f
<?php
/**
* @file
* Contains \Drupal\tour_test\Controller\TourTestController.
*/
namespace Drupal\tour_test\Controller;
use Drupal\Core\ControllerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Controller routines for tour_test routes.
*/
class TourTestController implements ControllerInterface {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static();
}
/**
* Outputs some content for testing tours.
*/
public function tourTest1() {
return array(
'tip-1' => array(
'#type' => 'container',
'#attributes' => array(
'id' => 'tour-test-1',
),
'#children' => t('Where does the rain in Spain fail?'),
),
'tip-4' => array(
'#type' => 'container',
'#attributes' => array(
'id' => 'tour-test-4',
),
'#children' => t('Tip created later?'),
),
);
}
/**
* Outputs some content for testing tours.
*/
public function tourTest2() {
return array(
'#type' => 'container',
'#attributes' => array(
'id' => 'tour-test-2',
),
'#children' => t('Pangram example'),
);
}
}
......@@ -12,13 +12,11 @@
*/
function tour_test_menu() {
$items['tour-test-1'] = array(
'page callback' => 'tour_test_1',
'access callback' => TRUE,
'route_name' => 'tour_test_1',
'title' => 'Tour test 1'
);
$items['tour-test-2/subpath'] = array(
'page callback' => 'tour_test_2',
'access callback' => TRUE,
'route_name' => 'tour_test_2',
'title' => 'Tour test 2'
);
return $items;
......@@ -42,41 +40,6 @@ function tour_test_tour_presave($entity) {
}
}
/**
* Page callback: output some content for testing tours.
*/
function tour_test_1() {
return array(
'tip-1' => array(
'#type' => 'container',
'#attributes' => array(
'id' => 'tour-test-1',
),
'#children' => t('Where does the rain in Spain fail?'),
),
'tip-4' => array(
'#type' => 'container',
'#attributes' => array(
'id' => 'tour-test-4',
),
'#children' => t('Tip created later?'),
),
);
}
/**
* Page callback: output some content for testing tours.
*/
function tour_test_2() {
return array(
'#type' => 'container',
'#attributes' => array(
'id' => 'tour-test-2',
),
'#children' => t('Pangram example'),
);
}
/**
* Implements hook_tour_tips_alter().
*/
......
tour_test_1:
pattern : 'tour-test-1'
defaults:
_content: '\Drupal\tour_test\Controller\TourTestController::tourTest1'
requirements:
_access: 'TRUE'
tour_test_2:
pattern : 'tour-test-2/subpath'
defaults:
_content: '\Drupal\tour_test\Controller\TourTestController::tourTest2'
requirements:
_access: 'TRUE'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment