Skip to content

Commit

Permalink
HSD8-1321 Remove and uninstall react paragraphs module (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Jun 17, 2022
1 parent 12ede21 commit 63d3ff2
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 286 deletions.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion config/default/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ module:
preprocess_event_dispatcher: 0
publishcontent: 0
rabbit_hole: 0
react_paragraphs: 0
readonly_field_widget: 0
real_aes: 0
redirect: 0
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions config/default/rest.resource.entity.paragraph_row.yml

This file was deleted.

19 changes: 0 additions & 19 deletions config/default/rest.resource.react_paragraphs.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drupal\Tests\hs_migrate\Unit\Plulgin\migrate\process;

use Drupal\hs_migrate\Plugin\migrate\process\SubProcess as HsSubProcess;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\migrate\process\SubProcess as OrigSubProcess;
use Drupal\migrate\Row;
Expand Down Expand Up @@ -30,8 +31,8 @@ public function testTranform() {

$value = simplexml_load_string('<data><item1><newkey>akey</newkey></item1></data>');
$new_value = $hs_plugin->transform($value, $migrate_executable, $row, 'field_foo');
$this->assertArrayEquals(['' => []], $new_value);
$this->expectException(\Error::class);
$this->assertEquals(['' => []], $new_value);
$this->expectException(MigrateException::class);
$original_plugin->transform($value, $migrate_executable, $row, 'field_foo');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ function su_humsci_profile_post_update_9200() {
$parent_type = $spotlight->get('parent_type')->getString();
$parent_id = $spotlight->get('parent_id')->getString();

if (!$parent_type || !\Drupal::entityTypeManager()->hasDefinition($parent_type)) {
if (!$parent_type || !\Drupal::entityTypeManager()
->hasDefinition($parent_type)) {
continue;
}
$parent = \Drupal::entityTypeManager()
Expand Down Expand Up @@ -243,3 +244,66 @@ function su_humsci_profile_post_update_9201() {
_su_humsci_profile_disable_paragraph('node', 'hs_basic_page', 'field_hs_page_components', 'hs_row');
_su_humsci_profile_enable_paragraph('node', 'hs_basic_page', 'field_hs_page_components', 'stanford_gallery');
}

/**
* Delete any react pararaphs fields.
*/
function su_humsci_profile_post_update_9202() {
$react_paragraphs_fields = [];
foreach (FieldConfig::loadMultiple() as $field) {
if (
$field->getType() == 'entity_reference_revisions' &&
$field->getSetting('handler') == 'default:paragraph_row'
) {
$react_paragraphs_fields[$field->getName()] = $field;
}
}
if ($react_paragraphs_fields) {
$paragraphs = \Drupal::entityTypeManager()
->getStorage('paragraph')
->loadByProperties(['parent_field_name' => array_keys($react_paragraphs_fields)]);
foreach ($paragraphs as $paragraph) {
$paragraph->delete();
}
}
$rows = \Drupal::entityTypeManager()
->getStorage('paragraph_row')
->loadMultiple();
foreach ($rows as $row) {
$row->delete();
}
foreach ($react_paragraphs_fields as $field) {
$field->delete();
}
$row_types = \Drupal::entityTypeManager()
->getStorage('paragraphs_row_type')
->loadMultiple();
foreach ($row_types as $row_type) {
$row_type->delete();
}
\Drupal::service('module_installer')->uninstall(['react_paragraphs']);
}

/**
* Fix reference to private files component that doesn't exist.
*/
function su_humsci_profile_post_update_9203() {
$paragraph_types = \Drupal::entityTypeManager()
->getStorage('paragraphs_type')
->loadMultiple();
foreach (FieldConfig::loadMultiple() as $field) {
if (
$field->getType() == 'entity_reference_revisions' &&
$field->getSetting('handler') == 'default:paragraph'
) {
$handler_settings = $field->getSetting('handler_settings');
if ($missing_paragraph_types = array_diff($handler_settings['target_bundles'], array_keys($paragraph_types))) {
foreach ($missing_paragraph_types as $unknown_paragraph_type) {
unset($handler_settings['target_bundles'][$unknown_paragraph_type]);
unset($handler_settings['target_bundles_drag_drop'][$unknown_paragraph_type]);
}
$field->setSetting('handler_settings', $handler_settings)->save();
}
}
}
}
Loading

0 comments on commit 63d3ff2

Please sign in to comment.