Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Using the Tour API code in a module (tour_builder)
/**
* Respond to updates to a tour object.
*
* @param \Drupal\tour\Plugin\Core\Entity\Tour $entity
* The tour object being updated.
*/
function hook_tour_update($entity) {
Drupal::service('plugin.manager.tour.tip')->clearCachedDefinitions();
cache('cache_tour')->deleteTags(array('tour_items'));
}
cause an exception
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "cache.cache_tour". Did you mean this: "cache.cache"? in Symfony\Component\DependencyInjection\Container->get() (line 289 of /Users/clemens/Sites/drupal/d8/www/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php).
The documentation state Respond to updates to a tour object but the code is about all tours so it seems.
Proposed resolution
Fix the code and bring the documentation in line :p
Remaining tasks
- The $entity should be used or the documentation should be changed.
- Fix the code example to work.
Comments
Comment #1
clemens.tolboomI needed to clear the list of tours
cache('config')->delete('find:tour.tour.');
which seems to work.Comment #10
quietone CreditAttribution: quietone as a volunteer commented@clemens.tolboom, thanks for reporting this problem and also commenting on the fix that worked for you.
This was discussed at a Bug Smash Initiative triage meeting with jibran and larowlan. There is no longer a 'cache_tour' and this is now outdated.
Comment #11
larowlanConfirming this was removed in #2216535: Replace Node overview topic and Node API topic with Entity Hooks topic