You are here

public function ParagraphsType::hasEnabledBehaviorPlugin in Paragraphs 8

Returns TRUE if $plugin_id is enabled on this ParagraphType Entity.

Parameters

string $plugin_id: The plugin id, as specified in the plugin annotation details.

Return value

bool TRUE if the plugin is enabled, FALSE otherwise.

Overrides ParagraphsTypeInterface::hasEnabledBehaviorPlugin

File

src/Entity/ParagraphsType.php, line 259

Class

ParagraphsType
Defines the ParagraphsType entity.

Namespace

Drupal\paragraphs\Entity

Code

public function hasEnabledBehaviorPlugin($plugin_id) {
  $plugins = $this
    ->getBehaviorPlugins();
  if ($plugins
    ->has($plugin_id)) {

    /** @var \Drupal\paragraphs\ParagraphsBehaviorInterface $plugin */
    $plugin = $plugins
      ->get($plugin_id);
    $config = $plugin
      ->getConfiguration();
    return array_key_exists('enabled', $config) && $config['enabled'] === TRUE;
  }
  return FALSE;
}