dougan1205 2015-02-25 17:08
浏览 43

如何构建我的CakePHP管理插件

I'm considering creating a plugin for the admin portion of my application and am seeking some guidance on how it should be structured. I will be using CakePHP 2.5.x.

Part 1:

I will be Auth as well as Acl. Should I be configuring this within /app/Controller/AppController.php or /app/Plugin/MyPlugin/Controller/MyPluginAppController.php?

Part 2:

Let's say I want to access the Post Model: /app/Model/AppController.php from within my plugin. What's the best way to do this within my plugin?

Which one of these files should I create to handle this? Do I even need to create a model within my plugin if I'm just extending the model from the main app?:

//Model
/app/Plugin/MyPlugin/Model/Post.php //Will this conflict with /app/Controller/PostsController.php?
/app/Plugin/MyPlugin/Model/MyPluginPost.php 

//Controller
/app/Plugin/MyPlugin/Controller/PostsController.php //Will this conflict with /app/Controller/PostsController.php?
/app/Plugin/MyPlugin/Controller/MyPluginPostsController.php 

How should I handle the data within the plugin's Post Controller? Am I on the right track with this?

<?php
// app/Plugin/MyPlugin/Controller/MyPluginAppController.php
App::uses('Posts.Post', 'Controller');
class MyPluginPostsController extends MyPluginAppController {

        public function index() {
            $this->Post->recursive = 0;
            $this->set('posts', $this->Paginator->paginate());
            return $this->Crud->execute();
        }
}

I realize I've asked a lot of questions, I just want to make sure what I'm doing is feasible/logical.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?