Skip to content

Commit

Permalink
Fixed bug when updated from 1.x to 3.x (#128)
Browse files Browse the repository at this point in the history
* Fixed bug when updated from 1.x to 3.x
  • Loading branch information
pookmish authored and sherakama committed Apr 28, 2017
1 parent 81ee5fa commit b2c3cac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
31 changes: 31 additions & 0 deletions modules/capx_filters/capx_filters.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* @file
* capx_filters.install
*/

use CAPx\Drupal\Util\CAPxMapper;
use CAPx\Drupal\Util\CAPxImporter;

/**
* Move filters from mapper to importer.
*/
function capx_filters_update_7300() {
$mappers = CAPxMapper::loadAllMappers();
$importers = CAPxImporter::loadAllImporters();
/** @var CAPx\Drupal\Entities\CFEntity $mapper */
foreach ($mappers as $mapper) {
if (!empty($mapper->filters)) {
/** @var CAPx\Drupal\Entities\CFEntity $importer */
foreach ($importers as $importer) {
if ($importer->mapper == $mapper->machine_name) {
$importer->settings['filters'] = $mapper->filters;
$importer->save();
}
}
unset($mapper->filters);
$mapper->save();
}
}
}
4 changes: 4 additions & 0 deletions stanford_capx.install
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ function stanford_capx_update_7201() {
* Resave each mapper so they get the new default config keys.
*/
function stanford_capx_update_7202() {
// When updating from before this to 3.x we need to add fields to prevent
// errors.
stanford_capx_update_7300();

$mappers = CAPxMapper::loadAllMappers();
foreach ($mappers as $mapper) {
$mapper->settings['multiple'] = FALSE;
Expand Down

0 comments on commit b2c3cac

Please sign in to comment.