cakephp插件模型/控制器缓存问题与主模型/控制器 [英] cakephp plugin model/controller cache issue with main model/controller
问题描述
我有一个带有用户模型,配置文件模型和用户控制器的插件,在此用户模型中与配置文件模型相关联。在我的主模型文件夹(在应用程序下),我有用户模型和用户控制器(这里我没有关联的配置文件)。有时,我收到错误说用户模型没有与配置文件模型相关联。还有时我得到错误 - 在用户控制器中失踪操作注销。我已经在app / controller / userscontroller中给出注销操作,但该方法在myplugin / usercontroller中不可用。 Im使用cakephp2.0 ..如何解决这个问题? cakephp如何设置模型和控制器的缓存?我不想完全禁用缓存。
I have a plugin with user model, profile model and an user controller, in this user model is associated with profile model. In my main model folder (under app), I have user model and user controller(here I have not associated with profile). Sometimes I'm getting errors saying that user model is not associated with profile model. Also sometimes I'm getting the error - "missing action logout in users controller". I have given the logout action in the app/controller/userscontroller but that method is not available in myplugin/usercontroller. Im using cakephp2.0.. How can I solve this issue ? How cakephp is setting the cache for models and controllers ? I don't want to completely disable the cache.
推荐答案
我也遇到了麻烦。基本上,这是由于Cake不支持具有相同类名的控制器的事实。因此,在插件和应用程序级别上名为 UsersController
的控制器会导致缓存和一些组件( Auth
组件示例)。
I've had trouble with this as well. Basically it comes down to the fact that Cake doesn't support controllers with the same class name. So a controller named UsersController
on plugin and app level will cause trouble with caching and some components (the Auth
component, for example).
在Cake应用程序的各个级别中支持相同的类名将在Cake 3.0中使用,这需要PHP 5.3,后者又支持命名空间正确处理重复的类名。
Support for identical classnames in various levels of a Cake application will come in Cake 3.0 which will require PHP 5.3, which in turn supports namespaces, a feature needed for correctly handling duplicate class names.
由于2.0分支刚刚超出了测试版,Cake 3.0将不会发布,所以我重构了我的插件,对我的控制器,视图和模型。
With no word on when Cake 3.0 will be released as the 2.0 branch is just out of beta, I refactored my plugin by prepending the plugin name to my controllers, views and models.
所以 UserModel
成为 PluginUserModel
和 UsersController
成为 PluginUsersController
。这是一个麻烦,因为你必须更新所有的视图和变量使用模型的名称。
So UserModel
became PluginUserModel
and UsersController
became PluginUsersController
. It's a bit of a hassle, because you have to update all the views and variables which use the model's name.
我的原始问题包含一些链接到Cake Bug跟踪器的类似问题,如果你有兴趣一些背景,
My original question contains some links to the Cake bug tracker where similar questions were raised, should you be interested in some background,
这篇关于cakephp插件模型/控制器缓存问题与主模型/控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!