Commit dc18a1b9 authored by Mark Fullmer's avatar Mark Fullmer Committed by Mark Fullmer
Browse files

Issue #3179983 by diegors, sophiavs, elber, beatrizrodrigues, mark_fullmer:...

Issue #3179983 by diegors, sophiavs, elber, beatrizrodrigues, mark_fullmer: Replace remaining language of 'whitelist'/'blacklist' in Layout Builder Restrictions module
parent 89f6ef4c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ INSTALLATION & MANAGEMENT IN THE UI
2. Expand the "Layout options" fieldset and choose either "Blocks available for
placement" or "Layouts available for placement". Initially, all blocks and
layouts are available, as would be the case if the module were not enabled.
For blocks, each "provider" is listed, and can either be whitelisted to allow
For blocks, each "provider" is listed, and can either be allowlisted to allow
all blocks from the given provider, or restricted with the "Choose specific..."
option:

+6 −6
Original line number Diff line number Diff line
@@ -14,21 +14,21 @@ layout_builder_restrictions.entity_view_mode_restriction:
      sequence:
        type: string
        label: 'Layout ID'
    blacklisted_blocks:
    denylisted_blocks:
      type: sequence
      label: 'Blacklisted blocks by category'
      label: 'Denylisted blocks by category'
      sequence:
        type: sequence
        label: 'Blacklisted blocks'
        label: 'Denylisted blocks'
        sequence:
          type: string
          label: 'Block ID'
    whitelisted_blocks:
    allowlisted_blocks:
      type: sequence
      label: 'Whitelisted blocks by category'
      label: 'Allowlisted blocks by category'
      sequence:
        type: sequence
        label: 'Whitelisted blocks'
        label: 'Allowlisted blocks'
        sequence:
          type: string
          label: 'Block ID'
+5 −5
Original line number Diff line number Diff line
@@ -126,12 +126,12 @@ function layout_builder_restrictions_update_8211(&$sandbox) {
}

/**
 * Relocate 'allowed_blocks' to 'whitelisted_blocks'.
 * Relocate 'allowed_blocks' to 'allowlisted_blocks'.
 */
function layout_builder_restrictions_update_8212(&$sandbox) {
  // When upgrading to 2.6, configuration for 'allowed_blocks'
  // is relocated to 'whitelisted_blocks' to distinguish from newly available
  // 'blacklisted_blocks' (which will default to an empty array for existing
  // is relocated to 'allowlisted_blocks' to distinguish from newly available
  // 'denylisted_blocks' (which will default to an empty array for existing
  // sites).
  $config_factory = \Drupal::configFactory();

@@ -147,8 +147,8 @@ function layout_builder_restrictions_update_8212(&$sandbox) {
      $allowed_blocks_by_category = $display->get('third_party_settings.layout_builder_restrictions.entity_view_mode_restriction.allowed_blocks');
      $display
        ->clear('third_party_settings.layout_builder_restrictions.entity_view_mode_restriction.allowed_blocks')
        ->set('third_party_settings.layout_builder_restrictions.entity_view_mode_restriction.whitelisted_blocks', $allowed_blocks_by_category)
        ->set('third_party_settings.layout_builder_restrictions.entity_view_mode_restriction.blacklisted_blocks', [])
        ->set('third_party_settings.layout_builder_restrictions.entity_view_mode_restriction.allowlisted_blocks', $allowed_blocks_by_category)
        ->set('third_party_settings.layout_builder_restrictions.entity_view_mode_restriction.denylisted_blocks', [])
        ->save();
    }
  }
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ layout_builder_restrictions.entity_view_mode_restriction_by_region:
      sequence:
        type: string
        label: 'Layout ID'
    whitelisted_blocks:
    allowlisted_blocks:
      type: sequence
      label: 'Layouts to be restricted'
      sequence:
@@ -23,7 +23,7 @@ layout_builder_restrictions.entity_view_mode_restriction_by_region:
            sequence:
              type: string
              label: Category
    blacklisted_blocks:
    denylisted_blocks:
      type: sequence
      label: 'Layouts to be restricted'
      sequence:
+21 −21
Original line number Diff line number Diff line
@@ -84,18 +84,18 @@ class AllowedBlocksForm extends FormBase {
  protected $tempData;

  /**
   * An array of whitelisted blocks, by category.
   * An array of allowlisted blocks, by category.
   *
   * @var array
   */
  protected $whitelistedBlocks;
  protected $allowlistedBlocks;

  /**
   * An array of blacklisted blocks, by category.
   * An array of denylisted blocks, by category.
   *
   * @var array
   */
  protected $blacklistedBlocks;
  protected $denylistedBlocks;

  /**
   * An array of restricted block categories.
@@ -159,8 +159,8 @@ class AllowedBlocksForm extends FormBase {
    $this->regionId = $current_request->query->get('region_id');
    $this->allowedBlockCategories = $display->getThirdPartySetting('layout_builder_restrictions', 'allowed_block_categories', []);
    $third_party_settings = $display->getThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction_by_region', []);
    $this->whitelistedBlocks = (isset($third_party_settings['whitelisted_blocks'][$this->layoutPluginId][$this->regionId])) ? $third_party_settings['whitelisted_blocks'][$this->layoutPluginId][$this->regionId] : [];
    $this->blacklistedBlocks = (isset($third_party_settings['blacklisted_blocks'][$this->layoutPluginId][$this->regionId])) ? $third_party_settings['blacklisted_blocks'][$this->layoutPluginId][$this->regionId] : [];
    $this->allowlistedBlocks = (isset($third_party_settings['allowlisted_blocks'][$this->layoutPluginId][$this->regionId])) ? $third_party_settings['allowlisted_blocks'][$this->layoutPluginId][$this->regionId] : [];
    $this->denylistedBlocks = (isset($third_party_settings['denylisted_blocks'][$this->layoutPluginId][$this->regionId])) ? $third_party_settings['denylisted_blocks'][$this->layoutPluginId][$this->regionId] : [];
    $this->restrictedCategories = (isset($third_party_settings['restricted_categories'][$this->layoutPluginId][$this->regionId])) ? $third_party_settings['restricted_categories'][$this->layoutPluginId][$this->regionId] : [];
  }

@@ -231,8 +231,8 @@ class AllowedBlocksForm extends FormBase {
        '#options' => [
          "all" => $this->t('Allow all existing & new %category blocks.', ['%category' => $data['label']]),
          "restrict_all" => $this->t('Restrict all existing & new %category blocks.', ['%category' => $data['label']]),
          "whitelisted" => $this->t('Allow specific %category blocks:', ['%category' => $data['label']]),
          "blacklisted" => $this->t('Restrict specific %category blocks:', ['%category' => $data['label']]),
          "allowlisted" => $this->t('Allow specific %category blocks:', ['%category' => $data['label']]),
          "denylisted" => $this->t('Restrict specific %category blocks:', ['%category' => $data['label']]),
        ],
        '#parents' => [
          'allowed_blocks',
@@ -336,7 +336,7 @@ class AllowedBlocksForm extends FormBase {
      foreach ($categories as $category => $category_setting) {
        $restriction_type = $category_setting['restriction'];
        $block_restrictions[$category]['restriction_type'] = $restriction_type;
        if (in_array($restriction_type, ['whitelisted', 'blacklisted'])) {
        if (in_array($restriction_type, ['allowlisted', 'denylisted'])) {
          foreach ($category_setting['allowed_blocks'] as $block_id => $block_setting) {
            if ($block_setting == '1') {
              // Include only checked blocks.
@@ -388,7 +388,7 @@ class AllowedBlocksForm extends FormBase {
  public function submitForm(array &$form, FormStateInterface $form_state) {}

  /**
   * Business logic to set category to 'all', 'whitelisted' or 'blacklisted'.
   * Business logic to set category to 'all', 'allowlisted' or 'denylisted'.
   *
   * @param string $category
   *   The block's category.
@@ -396,7 +396,7 @@ class AllowedBlocksForm extends FormBase {
   *   The data stored between AJAX submits or null.
   *
   * @return string
   *   The value 'all', 'whitelisted', 'blacklisted', or 'restrict_all'.
   *   The value 'all', 'allowlisted', 'denylisted', or 'restrict_all'.
   */
  protected function getCategoryBehavior($category, $temp_data) {
    // Check whether this is a newly available category that has been
@@ -408,18 +408,18 @@ class AllowedBlocksForm extends FormBase {
      return $temp_data[$category]['restriction_type'];
    }
    else {
      if (isset($this->whitelistedBlocks) && in_array($category, array_keys($this->whitelistedBlocks))) {
        return "whitelisted";
      if (isset($this->allowlistedBlocks) && in_array($category, array_keys($this->allowlistedBlocks))) {
        return "allowlisted";
      }
      elseif (isset($this->blacklistedBlocks) && in_array($category, array_keys($this->blacklistedBlocks))) {
        return "blacklisted";
      elseif (isset($this->denylistedBlocks) && in_array($category, array_keys($this->denylistedBlocks))) {
        return "denylisted";
      }
      elseif (in_array($category, $this->restrictedCategories)) {
        return 'restrict_all';
      }
      elseif ($category_is_restricted) {
        // If there is no configuration, but the category hasn't been 'allowed',
        // use 'whitelisted' to preset this as if all blocks were restricted.
        // use 'allowlisted' to preset this as if all blocks were restricted.
        return "restrict_all";
      }
      else {
@@ -429,7 +429,7 @@ class AllowedBlocksForm extends FormBase {
  }

  /**
   * Business logic to set category to 'all', 'whitelisted' or 'blacklisted'.
   * Business logic to set category to 'all', 'allowlisted' or 'denylisted'.
   *
   * @param string $block_id
   *   The Drupal block ID.
@@ -452,11 +452,11 @@ class AllowedBlocksForm extends FormBase {
      }
    }
    else {
      if (isset($this->whitelistedBlocks[$category])) {
        return in_array($block_id, $this->whitelistedBlocks[$category]);
      if (isset($this->allowlistedBlocks[$category])) {
        return in_array($block_id, $this->allowlistedBlocks[$category]);
      }
      if (isset($this->blacklistedBlocks[$category])) {
        return in_array($block_id, $this->blacklistedBlocks[$category]);
      if (isset($this->denylistedBlocks[$category])) {
        return in_array($block_id, $this->denylistedBlocks[$category]);
      }
      else {
        return FALSE;
Loading