Akelos Modules

Akelos Modules

IMPORTANT NOTE: Modules are not fully tested yet. Please report any issue on the Trac site.

Akelos Modules允许你归组,把很多controllers组织成一个形式。所以代替了你必须把所有的controllers放在同一个地方,现在你可以把他们拆开放在不同的地方。

为了告诉Akelos哪些modules是可用的,你需要在map中为这个新module添加一个规则,然后可以被specific controller所调度。

Routes, Mapping Requests to your modules

让我们说一下,如果你想把你所有的administration controllers和views归组放入admin module

那你将需要编辑config/routes.php文件,通过追加下面的代码来使你的应用程序知道这个新module

$Map->connect('/admin/:controller/:action/:id', array('controller' => 'dashboard', 'action' => 'index', 'module' => 'admin'));

before other routes.

Controller

现在你可以把dashboard controller放在app/controllers/admin/dashboard_controller.php用一个新的规则来声明这个controller。用ModuleName + “_”“给这个controller的名字加一个前缀。

class Admin_DashboardController extends AdminController
{
    //...
}

你可以继承基本的ApplicationController或者向上面代码所写的那样,继承一个特殊的controller。在你的module之后,Akelos需要一个controller,这个例子中是 app/controllers/admin_controller.php ,并且如果存在的话,它将会被加载,所以你的Admin_DashboardController可以继承于它。

class AdminController extends ApplicationController
{
}

Views

Akelos同时需要view,在/app/views/admin/controller_name下,和在/app/helpers/admin/下的helpers

如果你想有一个特殊的布局,Akelos会为你设定一个app/views/layouts/admin.tpl

Migrations

Installers也一样被应用于modules。在这个例子中,我们在app/installers/admin/*_installer.php下会有几个several installers/migrations app/installers/admin/*_installer.php。现在只需要一样,那就是告诉installer他属于那个module,如下

app/installers/admin/user_installer.php

class UserInstaller extends AkInstaller
{
    var $module = 'admin';
    // ***
}

Generators

controller generator支持generating modular controllers ,如下:

./script/generate controller Admin::Users
 
modules_cn.txt · Last modified: 2008/07/10 07:45 by liyh
 

The Akelos Framework was created by Bermi Ferrer and other contributors.
Potions of the code and documentation have been ported from Ruby on Rails.

The Akelos Framework is released under the LGPL license.

"Akelos", "Akelos Framework", and the Akelos logo are trademarks of Bermi Labs All rights reserved.

Wiki driven by DokuWiki