protected function IncludeExcludeStyleTrait::matchPattern in Block Style Plugins 8.2
Match a plugin ID against a list of possible plugin IDs.
Parameters
string $plugin_id: The ID of the block being checked.
array $plugin_list: List of plugin ids or plugin patterns of "plugin_id:*".
Return value
bool Return TRUE if the plugin ID matches a Plugin ID or pattern in the list.
2 calls to IncludeExcludeStyleTrait::matchPattern()
- IncludeExcludeStyleTrait::exclude in src/
IncludeExcludeStyleTrait.php - Exclude styles from appearing on blocks.
- IncludeExcludeStyleTrait::includeOnly in src/
IncludeExcludeStyleTrait.php - Only show styles on specific blocks.
File
- src/
IncludeExcludeStyleTrait.php, line 99
Class
- IncludeExcludeStyleTrait
- Provides a helper for determining whether to include or exclude a plugin.
Namespace
Drupal\block_style_pluginsCode
protected function matchPattern($plugin_id, array $plugin_list) {
// First check to see if the id is already directly in the list.
if (in_array($plugin_id, $plugin_list)) {
return TRUE;
}
// Now check to see if this ID is a derivative on something in the list.
preg_match('/^([^:]+):?/', $plugin_id, $matches);
if ($matches && in_array($matches[1] . ':*', $plugin_list)) {
return TRUE;
}
// Match any inline blocks in Layout Builder.
preg_match('/^inline_block:(.+)/', $plugin_id, $matches);
if ($matches && in_array($matches[1], $plugin_list)) {
return TRUE;
}
return FALSE;
}