You are here

function _gutenberg_is_gutenberg_enabled in Gutenberg 8.2

Checks whether Gutenberg is enabled for an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check.

Return value

bool Whether the entity is supported.

2 calls to _gutenberg_is_gutenberg_enabled()
gutenberg_entity_presave in ./gutenberg.module
Implements hook_entity_presave().
gutenberg_form_node_form_alter in ./gutenberg.module
Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.

File

./gutenberg.module, line 932
Provides integration with the Gutenberg editor.

Code

function _gutenberg_is_gutenberg_enabled(EntityInterface $entity = NULL) {
  if (!$entity) {
    return FALSE;
  }
  if ($entity
    ->getEntityTypeId() !== 'node') {
    return FALSE;
  }

  /*
   * TODO read from the entity type's third_party_settings instead of a global.
   *  @see menu_ui_form_node_form_alter()
   *  and https://www.sitepoint.com/drupal-8-third-party-settings-and-pseudo-fields/
   */
  $config = \Drupal::service('config.factory')
    ->get('gutenberg.settings');
  $node_type = $entity
    ->bundle();
  return (bool) $config
    ->get($node_type . '_enable_full');
}