You are here

public function EntityHelper::getSupportedEntityTypes in Simple XML sitemap 8.2

Same name and namespace in other branches
  1. 8.3 src/EntityHelper.php \Drupal\simple_sitemap\EntityHelper::getSupportedEntityTypes()

Returns objects of entity types that can be indexed.

Return value

array Objects of entity types that can be indexed by the sitemap.

File

src/EntityHelper.php, line 67

Class

EntityHelper
Class EntityHelper @package Drupal\simple_sitemap

Namespace

Drupal\simple_sitemap

Code

public function getSupportedEntityTypes() {
  $entity_types = $this->entityTypeManager
    ->getDefinitions();
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if (!$entity_type instanceof ContentEntityTypeInterface || !method_exists($entity_type, 'getBundleEntityType') || !$entity_type
      ->hasLinkTemplate('canonical')) {
      unset($entity_types[$entity_type_id]);
    }
  }
  return $entity_types;
}