willdurand / propel-publishable-behavior
此包已废弃且不再维护。未建议替代包。
关于此包最新版本(1.2.0)没有可用的许可证信息。
1.2.0
2014-02-04 13:24 UTC
Requires
- php: >=5.2.4
- propel/propel1: ~1.6
Requires (Dev)
- phpunit/phpunit: 3.7.*
README
PublishableBehavior 设计用于快速为您的模型添加发布/取消发布功能。
安装
在项目中安装行为,推荐使用 Composer
{ "require": { "willdurand/propel-publishable-behavior": "dev-master" } }
将以下行添加到您的 propel.ini
或 build.properties
配置文件中
propel.behavior.publishable.class = vendor.willdurand.propel-publishable-behavior.src.PublishableBehavior
注意:
vendor.willdurand.propel-publishable-behavior.src
是行为在点路径表示法中的路径。
用法
ActiveRecord API
如果对象已发布,则返回 true,否则返回 false
isPublished()
将对象标记为已发布
publish(PropelPDO $con = null)
将对象标记为未发布
unpublish(PropelPDO $con = null)
发布框架是否已开始?
hasPublicationEnded()
发布框架是否已开始?
hasPublicationStarted()
ActiveQuery API
将未发布对象包含在结果集中
includeUnpublished()
通过未独家发布的对象进行筛选
filterUnpublished()
通过独家发布的对象进行筛选
filterPublished()
通过活动发布进行筛选
filterByPublicationActive($date = 'now')
将对象标记为已发布
publish(PropelPDO $con = null)
将对象标记为未发布
unpublish(PropelPDO $con = null)
参数
<behavior name="publishable"> <parameter name="is_published_column" value="is_published" /> <parameter name="published_by_default" value="false" /> <parameter name="include_unpublished" value="false" /> <!-- timeframe support --> <parameter name="with_timeframe" value="false" /> <parameter name="published_at_column" value="published_at" /> <parameter name="published_until_column" value="published_until" /> <!-- start and end value can be null --> <parameter name="require_start" value="false" /> <parameter name="require_end" value="false" /> </behavior>
注意:参数
include_unpublished
允许您从每个查询中排除未发布对象。默认设置为false
。如果您不想排除未发布项,则必须将其设置为true
运行测试
首先,将 phpunit.xml.dist
复制到 phpunit.xml
。
如果您没有使用 Composer 安装 propel,请将 PROPEL_DIR
和 PHING_DIR
的值更改为自定义包含路径。通过更改 AUTOLOAD
属性来自定义自动加载器。
然后简单地启动
$ vendor/bin/phpunit -c phpunit.xml
都是绿色的吗?
鸣谢
- William Durand william.durand1@gmail.com
- Julien Muetton julien_muetton@carpe-hora.com