Jump to content

Migration priority in combination with RockSettings


gebeer
 Share

Recommended Posts

Hi @bernhard,

I just installed RockSettings for the first time on PW 3.0.210.

The project is still using CKEditor. So I got warnings for the TinyMCE fields that got installed through the RockSettings migration.

So I need to override those. I'm doing this in  site/migrate.php

/** @var RockMigrations $rm */
$rm = $this->wire->modules->get('RockMigrations');
$rm->watch(__FILE__, 0); // note priority set to 0 to execute before /site/modules/RockSettings/pageClasses/SettingsPage.php which has priority 1
$rm->migrate([
    'fields' => [],
    'templates' => [
        'rocksettings' => [
            'fields' => [
                'title' => [
                    'collapsed' => 4,
                ],
                'rocksettings_contact' => [
                    'collapsed' => Inputfield::collapsedNo,
                    'inputfieldClass' => 'InputfieldCKEditor',
                ],
				...

The migration takes no effect, because /site/modules/RockSettings/pageClasses/SettingsPage.php has priority 1 and site/migrate always has 9999, no matter what I set in the watch call. So the RockSettings migration always overrides my mygration in site/migrate.php

Here's the CLI output with $rm->watch(__FILE__, 0);

ddev exec php site/modules/RockMigrations/migrate.php
Refresh modules
##### SORTED WATCHLIST #####
Array
(
    [#9999] => Array
        (
            [0] => /var/www/html/site/migrate.php
        )

    [#1] => Array
        (
            [0] => /var/www/html/site/modules/RockSettings/pageClasses/SettingsPage.php
        )

)

### Migrate items with priority #9999 ###
Watchfile: /site/migrate.php
Load /var/www/html/site/migrate.php

### Migrate items with priority #1 ###
Watchfile: /site/modules/RockSettings/pageClasses/SettingsPage.php
  => RockSettings\SettingsPage::migrate()
---
Trigger RockMigrations::migrationsDone

This specific to site/migrate.php

After moving my migrations to site/modules/Site.module.php, the priority is recognized 

ddev exec php site/modules/RockMigrations/migrate.php
Refresh modules
##### SORTED WATCHLIST #####
Array
(
    [#1] => Array
        (
            [0] => /var/www/html/site/modules/RockSettings/pageClasses/SettingsPage.php
            [1] => /var/www/html/site/modules/Site/Site.module.php
        )

)

### Migrate items with priority #1 ###
Watchfile: /site/modules/RockSettings/pageClasses/SettingsPage.php
  => RockSettings\SettingsPage::migrate()
Watchfile: /site/modules/Site/Site.module.php
  ----- Migrate Module Site -----
  Migrate Site
---
Trigger RockMigrations::migrationsDone

Also after moving the migrations to Site::migrateSettingsPage like mentioned in the docs.

BTW the docs are currently not linked on https://www.baumrock.com/en/processwire/modules/rocksettings

But even if tmy migration is run after the RockSettingsPage one, the 'inputfieldClass' => 'InputfieldCKEditor',  takes no effect. If I set it manually via GUI, it gets reset to InputfieldTinyMCE after next migration.

This is because inputfieldClass can't be overriden in template context.

Before installing the TinyMCE fields in your RockSettingsPage, you could check if the module is available. If not, use InputfieldCKEditor. That would be great. I have sent you the adjusted site/modules/RockSettings/pageClasses/SettingsPage.php

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...