boboldehampsink / migrationshelper
此包已废弃,不再维护。未建议替代包。
Craft CMS 迁移助手插件
0.5.2
2015-09-25 12:14 UTC
Requires
- composer/installers: ~1.0
This package is not auto-updated.
Last update: 2022-02-01 12:51:12 UTC
README
帮助您编写复杂迁移的插件。
重要: 插件文件夹应命名为 "migrationshelper"。
弃用
随着2018年4月4日Craft 3的发布,此插件已被弃用。您仍然可以使用它与Craft 2,但鼓励使用(并开发)Craft 3版本。目前,我没有任何计划这样做。
提示
- 您不需要安装此插件。只要您需要助手文件,就可以使用其功能。
助手
getFieldGroupByName
<?php /** * Get a field group by name * * @param string $name * @return FieldGroupModel|null */ $group = MigrationsHelper::getFieldGroupByName($name);
addToFieldLayout
<?php /** * Append a field to a source's fieldlayout programmatically. * * @param BaseModel $source The element's source (e.g. a EntryTypeModel or CategoryGroupModel) * @param FieldModel $field The field's model * @param int $index The index of the field on the tab (optional - defaults to 0) * @param string $tabName The fieldlayout's tab (optional) * * @return BaseModel */ MigrationsHelper::addToFieldLayout(BaseModel $source, FieldModel $field, $index = 0, $tabName = ''); // Save source (e.g. Entry Type) craft()->sections->saveEntryType($source);
changeFieldSettings
<?php /** * Change the settings of a given field. * * @param string $context The field's context (e.g. global, matrixBlockType:1, etc.) * @param string $handle The field's handle * @param array $attributes An array of key/value settings */ MigrationsHelper::changeFieldSettings($context, $handle, array $attributes);
开发
在您的Craft安装中运行此命令以在提交Pull Request之前测试您对此插件所做的更改。
phpunit --bootstrap craft/app/tests/bootstrap.php --configuration craft/plugins/migrationshelper/phpunit.xml.dist --coverage-clover coverage.clover craft/plugins/migrationshelper/tests
变更日志
0.5.2
- 不要返回源对象,因为它已经是引用了。
- 如果tabName尚不存在,将空数组设置为默认布局。
0.5.1
- 在composer.json中添加了MIT许可证。
0.5.0
- 添加了getFieldGroupByName助手,以便轻松获取字段组。
0.4.0
- 改进了开发过程中的单元测试。
0.3.1
- 修复了字段上下文设置不正确的问题。
0.3.0
- 添加了在指定(标签)索引上插入字段的能力。
- ElementType不再是参数了。
- Tabname现在是可选的。
0.2.0
- 为开发添加了单元测试。
0.1.0
- 首次推送到GitHub。