You are here

public function IncludeExcludeStyleTrait::includeOnly in Block Style Plugins 8.2

Only show styles on specific blocks.

Determine if configuration should be only included on certain blocks when a block plugin id or block content type is passed from a plugin.

Parameters

string $plugin_id: The ID of the block being checked.

array $plugin_definition: A list of definitions for a block_style_plugins which could have the key 'include' set as a list of block plugin ids to allow.

Return value

bool Return True if the current block should only get the styles.

1 call to IncludeExcludeStyleTrait::includeOnly()
IncludeExcludeStyleTrait::allowStyles in src/IncludeExcludeStyleTrait.php
Determine whether a style should be allowed.

File

src/IncludeExcludeStyleTrait.php, line 74

Class

IncludeExcludeStyleTrait
Provides a helper for determining whether to include or exclude a plugin.

Namespace

Drupal\block_style_plugins

Code

public function includeOnly($plugin_id, array $plugin_definition) {
  $list = [];
  if (isset($plugin_definition['include'])) {
    $list = $plugin_definition['include'];
  }
  if (empty($list) || $this
    ->matchPattern($plugin_id, $list)) {
    return TRUE;
  }
  return FALSE;
}