You are here

public function YoastSeoManager::getEnabledBundles in Real-time SEO for Drupal 8

Returns an array of bundles Yoast SEO has been enabled for.

Parameters

string $entity_type: The entity.

Return value

array A list of enabled bundles as $id => $label.

File

src/YoastSeoManager.php, line 134

Class

YoastSeoManager
Class YoastSeoManager.

Namespace

Drupal\yoast_seo

Code

public function getEnabledBundles($entity_type = 'node') {
  $enabled_bundles = array();
  $yoast_seo_field_manager = \Drupal::service('yoast_seo.field_manager');

  // Get the available bundles Yoast SEO supports.
  $bundles = $this
    ->getAvailableBundles($entity_type);

  // Retrieve the bundles for which Yoast SEO has already been enabled for.
  foreach ($bundles as $bundle_id => $bundle_label) {
    if ($yoast_seo_field_manager
      ->isAttached($entity_type, $bundle_id, 'field_yoast_seo')) {
      $enabled_bundles[] = $bundle_id;
    }
  }
  return $enabled_bundles;
}