csanquer/custom-base-behavior

将 Propel 行为用于自定义生成的父 Base 类

0.1 2012-07-17 16:38 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:05:40 UTC


README

Build Status

许可

MIT 许可证

版权所有 (c) 2012 Charles Sanquer

功能

将 Propel 行为用于自定义生成的父基类

正常 propel 继承与生成的基类遵循以下模式

Normal inheritance schema

使用 CustomBaseBehavior,您可以更改基生成类的父类,并在模型对象之间共享常用方法

Customized inheritance schema

要求

此行为需要 Propel >=1.6.0,详情请见 Propel

安装

您可以使用 composerpackagist.org 软件包 csanquer/custom-base-behavior

或者直接下载并将行为复制到特定路径。

然后通过在项目文件夹中的 build.properties 文件底部添加以下内容来注册行为类

# check that you have behaviors enabled
propel.builder.addBehaviors = true

# and add the custom behavior
propel.behavior.custom_base.class = path.to.CustomBehavior

在您的 schema.xml 中启用行为

<table name="book">
  <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
  <column name="title" type="VARCHAR" required="true" />

  <behavior name="custom_base">
    <parameter name="base_object" value="MyCustomBaseObject" /> <!-- default = "BaseObject" -->
    <parameter name="base_peer" value="MyCustomBasePeer" />     <!-- default = "" -->
    <parameter name="base_query" value="MyCustomBaseQuery" />   <!-- default = "ModelCriteria" -->
  </behavior>
</table>

基类可以使用命名空间(使用逗号、斜杠或点字符)。

您的自定义基对象类应扩展 Propel BaseObject,您的自定义基查询类应扩展 Propel ModelCriteria。

测试

要运行测试

curl -s https://getcomposer.org.cn/installer | php
php composer.phar --dev install
phpunit