Skip to content
Snippets Groups Projects
Commit da6f857f authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-3369: initial commit

parents
No related branches found
No related tags found
No related merge requests found
langcode: en
status: true
dependencies: { }
id: uw_lbs_carousel_1_item
label: 'Carousel - 1 item'
classes: uw-carousel--one-item
type: component
block_restrictions:
- 'inline_block:uw_cbl_facts_and_figures'
langcode: en
status: true
dependencies: { }
id: uw_lbs_carousel_2_items
label: 'Carousel - 2 items'
classes: uw-carousel--two-items
type: component
block_restrictions:
- 'inline_block:uw_cbl_facts_and_figures'
langcode: en
status: true
dependencies: { }
id: uw_lbs_carousel_3_items
label: 'Carousel - 3 items'
classes: uw-carousel--three-items
type: component
block_restrictions:
- 'inline_block:uw_cbl_facts_and_figures'
langcode: en
status: true
dependencies: { }
id: uw_lbs_carousel_4_items
label: 'Carousel - 4 items'
classes: uw-carousel--four-items
type: component
block_restrictions:
- 'inline_block:uw_cbl_facts_and_figures'
langcode: en
status: true
dependencies: { }
id: uw_lbs_contained_width
label: 'Contained width'
classes: uw-contained-width
type: section
block_restrictions:
- 'inline_block:uw_cbl_call_to_action'
- 'inline_block:uw_cbl_copy_text'
- 'inline_block:uw_cbl_facebook'
- 'inline_block:uw_cbl_facts_and_figures'
- 'inline_block:uw_cbl_image'
- 'inline_block:uw_cbl_remote_video'
langcode: en
status: true
dependencies: { }
id: uw_lbs_full_width
label: 'Full width'
classes: uw-full-width
type: section
block_restrictions:
- 'inline_block:uw_cbl_call_to_action'
- 'inline_block:uw_cbl_copy_text'
- 'inline_block:uw_cbl_facebook'
- 'inline_block:uw_cbl_facts_and_figures'
- 'inline_block:uw_cbl_image'
- 'inline_block:uw_cbl_remote_video'
<?php
namespace Drupal\uw_cfg_common\CustomBlocks;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\preprocess_event_dispatcher\Event\BlockPreprocessEvent;
/**
* Class UwCblBase.
*/
class UwCblBase {
/**
* Check that we are on a layout builder add/edit form and that we are on
* a specified block.
*
* @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
* The event.
* @param string $block_name
* The human readable name of the block.
* @return boolean
*/
public function checkLayoutBuilder(FormAlterEvent $event, string $block_name): bool {
// Get the form from the event.
$form = &$event->getForm();
// Get the form_id from the form object.
$form_id = $form['#form_id'];
// Form ids to check for.
$form_ids = ['layout_builder_update_block', 'layout_builder_add_block'];
// If we are not in a layout builder, exit the function.
if (!in_array($form_id, $form_ids)) {
return FALSE;
}
// Check for correct block name.
if (isset($form['settings']['admin_label']['#plain_text']) && $form['settings']['admin_label']['#plain_text'] == $block_name) {
return TRUE;
}
else {
return FALSE;
}
}
/**
* Check if we have the correct block id to preprocess.
*
* @param Drupal\hook_event_dispatcher\Event\Preprocess\BlockPreprocessEvent $event
* The event.
* @param string $block_id
* The id of the block to check.
* @return boolean
*/
public function checkPreprocessBlock(BlockPreprocessEvent $event, string $block_id): bool {
// Get the variables from the event.
$variables = $event->getVariables();
// If the plugin does not much the block id, return negative.
if ($variables->get('derivative_plugin_id') !== $block_id) {
return FALSE;
}
return TRUE;
}
}
required: true
name: UW Configure custom blocks
description: Configure all of UW custom blocks
type: module
core_version_requirement: ^8 || ^9
dependencies:
- core_event_dispatcher
- field_event_dispatcher
- hook_event_dispatcher
- layout_builder_modal
- layout_builder_restrictions
- layout_builder_styles
- preprocess_event_dispatcher
<?php
/**
* Implements hook_form_FORM_ID_alter().
*
* Remove the None option from layout builder styles.
*/
function uw_cfg_common_form_layout_builder_configure_section_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// Remove the None option from layout builder styles.
unset($form['layout_builder_style']['#empty_option']);
// Ensuring that the contained width is selected by default.
$form['layout_builder_style']['#default_value'] = $form['layout_builder_style']['#default_value'] ? $form['layout_builder_style']['#default_value'] : 'uw-contained-width';
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment