You are here

public function GatsbyPreview::isPreviewEntity in Gatsby Live Preview & Incremental Builds 2.0.x

Same name and namespace in other branches
  1. 8 src/GatsbyPreview.php \Drupal\gatsby\GatsbyPreview::isPreviewEntity()

Verify the entity is selected to sync to the Gatsby site.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

Return value

bool If the entity type should be sent to Gatsby Preview.

File

src/GatsbyPreview.php, line 138

Class

GatsbyPreview
Defines a class for generating Gatsby based previews.

Namespace

Drupal\gatsby

Code

public function isPreviewEntity(ContentEntityInterface $entity) {
  $entityType = $entity
    ->getEntityTypeId();
  $selectedEntityTypes = $this->configFactory
    ->get('gatsby.settings')
    ->get('preview_entity_types') ?: [];
  return in_array($entityType, array_values($selectedEntityTypes), TRUE);
}