Caching plugin and normal controllers with duplicate names

寵の児 提交于 2019-12-02 08:48:45

May be it would be helpfull to override Cake' standard cache file names for Plugin to make Cache engine keep it separately. In main bootstrap file while loading plugin:

CakePlugin::loadAll(array('Plugin' => array('bootstrap' => true));

In Plugin direcrory /app/Plugin/Plugin/Config/bootstrap.php

<?php
Cache::config('_cake_core_', array(
    'engine' => 'File',
    'prefix' => 'cake_core_plugin_',
    'path' => CACHE . 'persistent' . DS,
    'serialize' => true,
    'duration' => '+999 days',
));
?>

Are there conflicting routes between the main app and the plugin? This sounds like you may need to create a route for your /posts and another for /admin/posts in your main app. This should override the routes from the plugin causing any conflict. Of course, clear your cache before trying the change.

//main app posts route
Router::connect(
    '/posts',
    array(
        'controller' => 'Posts'
        'action' => 'index'
    )
);

//plugin posts route
Router::connect(
    '/admin/posts',
    array(
        'controller' => 'Posts'
        'action' => 'index',
        'plugin' => 'CmsPlugin'
    )
);

This turns out to be a known issue (which doesn't make it less annoying) and will only be fixed in a next major release, as per this Cake bug report.

PHP 5.2 doesn't have namespace support which is apparently needed for Cake to support duplicate classnames. PHP 5.3 has namespace support and Cake 3.0 will require that version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!