diff --git a/core/modules/tour/lib/Drupal/tour/Entity/Tour.php b/core/modules/tour/lib/Drupal/tour/Entity/Tour.php index 35a33b2..a8523bd 100644 --- a/core/modules/tour/lib/Drupal/tour/Entity/Tour.php +++ b/core/modules/tour/lib/Drupal/tour/Entity/Tour.php @@ -55,11 +55,11 @@ class Tour extends ConfigEntityBase implements TourInterface { public $label; /** - * The paths in which this tip can be displayed. + * The routes on which this tour should be displayed. * * @var array */ - protected $paths = array(); + protected $routes = array(); /** * Holds the collection of tips that are attached to this tour. @@ -123,7 +123,7 @@ public function getTips() { public function getExportProperties() { $properties = parent::getExportProperties(); $names = array( - 'paths', + 'routes', 'tips', ); foreach ($names as $name) { diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php index fcae023..d1cd36d 100644 --- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php +++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php @@ -129,8 +129,8 @@ public function testTourFunctionality() { 'id' => 'tour-entity-create-test-en', 'label' => 'Tour test english', 'langcode' => 'en', - 'paths' => array( - 'tour-test-1', + 'routes' => array( + 'tour_test.1', ), 'tips' => array( 'tour-test-1' => array( diff --git a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test-2.yml b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test-2.yml index 62e5ae8..425789f 100644 --- a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test-2.yml +++ b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test-2.yml @@ -2,8 +2,8 @@ id: tour-test-2 module: tour_test label: Tour test english langcode: en -paths: - - tour-test-2/* +routes: + - tour_test.2 tips: tour-test-2: id: tour-test-2 diff --git a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml index 3fa6d5c..5b8ba2b 100644 --- a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml +++ b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml @@ -2,8 +2,8 @@ id: tour-test module: tour_test label: Tour test english langcode: en -paths: - - tour-test-1 +routes: + - tour_test.1 tips: tour-test-1: id: tour-test-1 diff --git a/core/modules/tour/tour.module b/core/modules/tour/tour.module index 8bd9ec1..af7ffc3 100644 --- a/core/modules/tour/tour.module +++ b/core/modules/tour/tour.module @@ -5,6 +5,7 @@ * Main functions of the module. */ use Drupal\Core\Cache\CacheBackendInterface; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** * Implements hook_permission(). @@ -108,22 +109,12 @@ function tour_preprocess_page(&$variables) { return; } - // @todo replace this with http://drupal.org/node/1918768 once it is committed. - $path = current_path(); - // Load all of the items and match on path. - $tours = entity_load_multiple('tour'); - - $path_alias = drupal_strtolower(\Drupal::service('path.alias_manager')->getPathAlias($path)); - foreach ($tours as $tour_id => $tour) { - // @todo Replace this with an entity query that does path matching when - // http://drupal.org/node/1918768 lands. - $pages = implode("\n", $tour->getPaths()); - if (!drupal_match_path($path_alias, $pages) && (($path == $path_alias) || drupal_match_path($path, $pages))) { - unset($tours[$tour_id]); - } - } - - if ($tours) { + // Load all of the items and match on route name. + $route_name = \Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME); + $results = \Drupal::entityQuery('tour') + ->condition('routes.*', $route_name) + ->execute(); + if (!empty($results) && $tours = entity_load_multiple('tour', array_keys($results))) { $variables['page']['help']['tour'] = entity_view_multiple($tours, 'full'); } } diff --git a/core/modules/views_ui/config/tour.tour.views-ui.yml b/core/modules/views_ui/config/tour.tour.views-ui.yml index a7e6fa9..8e2ec3e 100644 --- a/core/modules/views_ui/config/tour.tour.views-ui.yml +++ b/core/modules/views_ui/config/tour.tour.views-ui.yml @@ -3,8 +3,9 @@ uuid: 261db4f0-603c-440d-8211-17a095614851 module: views_ui label: 'Views ui' langcode: en -paths: - - 'admin/structure/views/view/*' +routes: + - views_ui.edit + - views_ui.edit_display tips: views-ui-active-display: id: views-ui-active-display