Skip to content

Commit

Permalink
Issue #65: Allow developers to alter the allowed values for (Content …
Browse files Browse the repository at this point in the history
…row: Column layout).
  • Loading branch information
msnassar committed Aug 9, 2019
1 parent 1b175fd commit bbb4678
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
24 changes: 24 additions & 0 deletions oe_paragraphs.api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* @file
* Hooks for the OE Paragraphs module.
*/

declare(strict_types = 1);

/**
* Alters the allowed values for "Content row: Column layout".
*
* @param array $allowed_values
* Array of possible key and value options.
*
* @see _oe_paragraphs_allowed_values_content_row_column_layout()
*/
function hook_oe_paragraphs_allowed_values_content_row_column_layout_alter(array &$allowed_values) {
$allowed_values = [
'2' => t('2 columns (equal width | 6-6)'),
'6-3-3' => t('3 columns (non-equal width | 6-3-3)'),
'4' => t('4 columns (equal width | 3-3-3-3)'),
];
}
5 changes: 4 additions & 1 deletion oe_paragraphs.module
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ function oe_paragraphs_entity_base_field_info(EntityTypeInterface $entity_type):
* @see options_allowed_values()
*/
function _oe_paragraphs_allowed_values_content_row_column_layout(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, $cacheable): array {
return [
$allowed_values = [
'2' => t('2 columns (equal width | 6-6)'),
'8-4' => t('2 columns (non-equal width | 8-4)'),
'3' => t('3 columns (equal width | 4-4-4)'),
'3-6-3' => t('3 columns (non-equal width | 3-6-3)'),
];

\Drupal::moduleHandler()->alter('oe_paragraphs_allowed_values_content_row_column_layout', $allowed_values);
return $allowed_values;
}

0 comments on commit bbb4678

Please sign in to comment.