我正在研究一个现有的Drupal 8站点。我正在改变routing.yml中的任何东西。
在一个routing.yml文件中,我有以下内容。
user_profile_update.callback:
path: '/user-update'
defaults:
_controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser'
requirements:
_user_is_logged_in: 'TRUE'
_permission: 'access content'我想将控制器的方法更改为\Drupal\user_profile\Controller\ProfileUpdateController::updateUser123(),但是在编辑了路由定义之后,ProfileUpdateController类仍然使用updateUser()方法。
我用下面的SQL从数据库中删除了所有缓存表,但是控制器仍然没有使用updateUser123()方法。
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;我怎样才能解决这个问题?
发布于 2018-02-27 09:59:13
您的意思是您的routing.yml文件中有这样的内容:
user_profile_update.callback:
path: '/user-update'
defaults:
_controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser'
requirements:
_user_is_logged_in: 'TRUE'
_permission: 'access content'你还在打电话给updateUser而不是updateUser123
您的控制器应该如下所示:
class ProfileUpdateController extends ControllerBase {
public function updateUser123() {
//your code here
}
}现在您需要调用该方法:
user_profile_update.callback:
path: '/user-update'
defaults:
_controller: '\Drupal\user_profile\Controller\ProfileUpdateController::updateUser123'
requirements:
_user_is_logged_in: 'TRUE'
_permission: 'access content'此外,我建议使用钻地清除缓存。这将清空所有缓存,并重新生成执行页面请求所需的数据。
https://drupal.stackexchange.com/questions/256665
复制相似问题