0

I'm working on an existing Drupal 8 site. I'm changing anything in routing.yml.

In a routing.yml file I have the following.

user_profile_update.callback:
  path: '/user-update'
  defaults:
    _controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser'
  requirements:
    _user_is_logged_in: 'TRUE'
    _permission: 'access content'

I want to change the controller's method to \Drupal\user_profile\Controller\ProfileUpdateController::updateUser123(), but after editing the route definition, the ProfileUpdateController class is still using the updateUser() method.

I removed all the cache tables from the database with the following SQL, but the controller is still not using the updateUser123() method.

TRUNCATE cache_config;
TRUNCATE cache_container;
TRUNCATE cache_data;
TRUNCATE cache_default;
TRUNCATE cache_discovery;
TRUNCATE cache_dynamic_page_cache;
TRUNCATE cache_entity;
TRUNCATE cache_menu;
TRUNCATE cache_render;
TRUNCATE cache_toolbar;

How can I fix the issue?

  • 1
    if you rename the routing file to something random, and clear the cache, does the /user-update path still work? – No Sssweat Feb 27 '18 at 9:50
  • yes path works properly.. – Akhtar Feb 27 '18 at 10:05
  • Well that should be impossible. Do you have multiple environments of your website? Perhaps you're changing the files of a particular environment and looking at a different environment on your browser. – No Sssweat Feb 27 '18 at 21:29
0

You're saying that you have this in your routing.yml file:

user_profile_update.callback:
  path: '/user-update'
  defaults:
    _controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser'
  requirements:
    _user_is_logged_in: 'TRUE'
    _permission: 'access content'

You're still calling updateUser and not updateUser123

Your controller should be looking like this:

class ProfileUpdateController extends ControllerBase {

  public function updateUser123() {
  //your code here
  }

}

And now you'll need to call the method:

user_profile_update.callback:
  path: '/user-update'
  defaults:
    _controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser123'
  requirements:
    _user_is_logged_in: 'TRUE'
    _permission: 'access content'

Also I recommend clearing your cache with Drush. This will empty all caches and rebuild the data required for Drupal to execute the page request

  • Thanks for your response. I'm calling _controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser123' in my routing.yml and renamed my controlller function updateUser123 Also, I have cleared Drupal cache using drush cr and also cleared cache tables in DB. Also, I have turned off Drupal caching. Still my code calls the old route method. – Akhtar Feb 28 '18 at 7:29
  • Have you tried re-creating your routing.yml file? Or you can perhaps try to reproduce it by doing the same in a new project? – Ducky Feb 28 '18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.