Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Apr 22, 2024
1 parent d8588b2 commit 843a894
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions modules/caw_profile_helper/caw_profile_helper.module
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,6 @@ use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;
use Drupal\Core\Cache\Cache;

function mikes() {
$field_name = 'caw_benefits_foobarbaz';
$options = ['below' => 'caw_benefits_med_maternity_stay'];
$label = NULL;
/** @var \Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay $view */
$view = \Drupal::entityTypeManager()
->getStorage('entity_view_display')
->load('node.caw_benefits.default');
foreach ($view->getSections() as $section) {
foreach ($section->getComponents() as $component) {
$component_config = $component->get('configuration');
if (str_ends_with($component->getPluginId(), $options['below'])) {
$uuid = \Drupal::service('uuid')->generate();
$new_config = $component_config;
$new_config['id'] = str_replace($options['below'], $field_name, $new_config['id']);
$new_config['label'] = $label?: $field_name;
$new_component = new \Drupal\layout_builder\SectionComponent($uuid, $component->getRegion(),$new_config);
$new_component->setWeight($component->getWeight() + 1);

$section->insertAfterComponent($component->getUuid(), $new_component);
$view->save();
return;
}
}
}
}

/**
* Implements hook_paragraphs_behavior_info_alter().
*/
Expand Down

0 comments on commit 843a894

Please sign in to comment.