2017 © Pedro Peláez
 

craft-plugin migrationshelper

Migrations Helper Plugin for Craft CMS

image

boboldehampsink/migrationshelper

Migrations Helper Plugin for Craft CMS

  • Thursday, April 5, 2018
  • by boboldehampsink
  • Repository
  • 1 Watchers
  • 15 Stars
  • 836 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

DEPRECATED - Migrations Helper plugin for Craft CMS Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

Plugin that helps you write complex migrations., (*1)

Important: The plugin's folder should be named "migrationshelper", (*2)

Deprecated

With the release of Craft 3 on 4-4-2018, this plugin has been deprecated. You can still use this with Craft 2 but you are encouraged to use (and develop) a Craft 3 version. At this moment, I have no plans to do so., (*3)

Tips

  • You don't need to install this plugin. As long as you require the helper file you can use its functions.

Helpers

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);

Development

Run this from your Craft installation to test your changes to this plugin before submitting a Pull Request, (*4)

phpunit --bootstrap craft/app/tests/bootstrap.php --configuration craft/plugins/migrationshelper/phpunit.xml.dist --coverage-clover coverage.clover craft/plugins/migrationshelper/tests

Changelog

0.5.2

  • Don't return source object as its already by reference
  • Set an empty array as default layout for the tabName in case it does not exist yet

0.5.1

  • Added MIT license to composer.json

0.5.0

  • Added getFieldGroupByName helper to easily get field groups

0.4.0

  • Improved unit tests for development

0.3.1

  • Fixed field context not setting correctly

0.3.0

  • Added the ability to insert the field on a specified (tab) index
  • ElementType is not an argument anymore
  • Tabname is now optional

0.2.0

  • Added unit tests for development

0.1.0

  • Initial push to GitHub

The Versions

05/04 2018

dev-master

9999999-dev

Migrations Helper Plugin for Craft CMS

  Sources   Download

MIT

The Requires

 

25/09 2015

dev-develop

dev-develop

Migrations Helper Plugin for Craft CMS

  Sources   Download

MIT

The Requires

 

25/09 2015

0.5.2

0.5.2.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

MIT

The Requires

 

17/09 2015

0.5.1

0.5.1.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

MIT

The Requires

 

16/09 2015

0.5.0

0.5.0.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

The Requires

 

16/09 2015

0.4.0

0.4.0.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

The Requires

 

16/09 2015

0.3.1

0.3.1.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

The Requires

 

16/09 2015

0.3.0

0.3.0.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

The Requires

 

15/09 2015

0.2.0

0.2.0.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

The Requires

 

10/09 2015

0.1.0

0.1.0.0

Migrations Helper Plugin for Craft CMS

  Sources   Download

The Requires