heyday/silverstripe-versioneddataobjects
Composer 安装命令:
composer require heyday/silverstripe-versioneddataobjects
包简介
Provides Versioned DataObjects in SilverStripe
README 文档
README
This module provides an easy to use implementation of SilverStripe's built-in Versioned extension for DataObjects, along with admin components to manage your versioned things.
IMPORTANT: Versioning of DataObjects is built-in to the Versioned extension in SilverStripe 4.x and newer.
Installation (with composer)
$ composer require heyday/silverstripe-versioneddataobjects
Usage
The VersionedDataObject extension adds the same draft/published versioning used for pages to your own DataObjects, and any subclasses they have. Only fields in the table of a DataObject with this extension will be versioned. Related DataObjects need VersionedDataObject applied separately if required.
class Slice extends DataObject { private static $db = [ 'Content' => 'Text' ]; private static $has_one = [ 'Parent' => 'SiteTree' ]; private static $extensions = [ 'Heyday\VersionedDataObjects\VersionedDataObject' ]; }
Versioned DataObjects in a GridField
To use VersionedDataObject records in a GridField, GridFieldDetailForm needs to be replaced with VersionedDataObjectDetailsForm:
// ... public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab( 'Root.Slices', new GridField( 'Slices', 'Slices', $this->Slices(), $config = GridFieldConfig_RelationEditor::create() ) ); $config->removeComponentsByType('GridFieldDetailForm'); $config->addComponent(new Heyday\VersionedDataObjects\VersionedDataObjectDetailsForm()); return $fields; } // ...
Versioned DataObjects in a ModelAdmin
class SliceAdmin extends Heyday\VersionedDataObjects\VersionedModelAdmin { private static $menu_title = 'Slices'; private static $url_segment = 'slice'; private static $managed_models = [ 'Slice' ]; }
Cavets / Troubleshooting
SilverStripe's versioning system uses global state to keep track of a "reading mode" that affects which tables records are read from and written to for all uses of the Versioned extension. This works on the front end of a site where you expect to see the currently selected stage, however it also alters what records are visible in the CMS if not adjusted for. The admin components supplied with this module work around this to always show draft records in the CMS.
If you have control over an ORM query, you can alter the behaviour of Versioned with DataQuery parameters to override the global reading mode setting:
VersionedFoo::get() ->setDataQueryParam(['Versioned.stage' => 'Stage']);
If you can't modify a query, you can use VersionedReadingMode from this module to change and restore the global reading mode around a piece of code:
VersionedReadingMode::setStageReadingMode(); // ... code that runs queries VersionedReadingMode::restoreOriginalReadingMode();
If you suspect you might be seeing an issue from incorrect reading mode, the global reading mode can be changed between live and stage by adding the query string ?stage=Stage or ?stage=Live to the current URL.
BetterButtons compatibility
This module works with unclecheese/betterbuttons version 1.2.8.
Unit testing
None :(
##License
SilverStripe Versioned DataObjects is licensed under an MIT license
heyday/silverstripe-versioneddataobjects 适用场景与选型建议
heyday/silverstripe-versioneddataobjects 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 211.93k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2013 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 heyday/silverstripe-versioneddataobjects 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 heyday/silverstripe-versioneddataobjects 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 211.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 3
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-07-14

