来源于:http://trac.seagullproject.org/wiki/Howto/WorkingWithModules

使用模块

本文档制作中 ..

概述

模块是框架的主要拓展功能,开发人员通过使用框架提供的资源创建和修改模块来开发他们的应用程序的功能

安装模块

卸载模块

一个模块提供

  • 一个数据存取对象
  • 商务逻辑类,包括Controller和Observers
  • 一套数据库表集合,默认样品数据
  • 数据表别名
  • ORM 映射
  • GUI(图形用户界面)的翻译
  • 配置数据
  • 导航数据
  • 用于页面输出的 html/xml 的模板
  • web 元素,如CSS,javascript,images/media
  • 单元测试和功能测试

链接Web 元素

Win32平台不支持文件的符号链接(也有翻译成软链接)(除非是Vista以上版本)。Windows 用户可通过下列方法模仿文件符号链接。

  • 注意:你的PHP必须是配置成能够运行exec()
 1. 下载 http://www.dynawell.com/reskit/microsoft/win2000/linkd.zip
 2. 解压,并把linkd.exe放到 C:\Windows\System32 或 C:\WINNT\System32 目录

这样,symlink()函数就可以和Linux/Mac一样的在Windows使用。

从: http://fr.php.net/manual/fr/function.symlink.php#56654 改编而来

扩展和自定义模块注册

载入数据

A schematic for data deps in task loading:

1) default data -> modules IDs, perms/roles
2) sample data -> whatever u like, just to populate model for demo purposes
3) custom data -> data specific for your app, in most cases all you need to extend svn base code
4) navigation -> requires roles IDs, module IDs (created in 1)
5) block data -> requires section/page IDs, roles IDs (created in above)

模块初始化

If a file named init.php is discovered in the root of your module, it will be loaded on every request whether the specific module is requested or not. 如果在你的模块的根目录下有一个init.php文件,那么这个文件在每次请求时被载入而不管这个模块是不是当前模块。

如,CMS的init文件可能定义了一些常量会在Foo模块中用到,因为Foo模块使用了CMS模块的功能。但是如果只是请求Foo模块也仍然需要使用那些常量。全局的载入init文件正量出于这种考虑。

重建模块

我们可以给seagull重建过程添的任务栈添加任务。一个例子是当你需要在数据库中设置存储过程,视图,函数。因为PEAR对分界符语法会有问题,你可能想直接执行SQL文件。尝试下面几个步骤:

 1. 创建一个自定义的任务,只要将它放到你的模块的根目录下它就会在重建seagull时自动被读取并调用
 2. 直接使用shell_exec()调用mysql,将你的sql文件的路径传给它,直接执行
 3. 将task的名字添加到
$conf['site']['customRebuildTasks']

测试

单元测试

按照seagull其它范例模块的命名方式将你的测试文件命名并将它们放到你的模块的tests文件夹下,这样就会在执行Test Runner时在目录树下会显示模块的单元测试结点。

功能测试

将你的web测试文件也放到你的tests文件夹下,要让它们显示在Selenium test runner目录树下,你必须在seagull/tests/SeleniumTestSuite.html文件中引用这些文件。

 
howto/workingwithmodules.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2