You are here

public function EntityManager::disableEntityType in Simple XML sitemap 4.x

Disables sitemap support for an entity type. Disabling support for an entity type deletes its sitemap settings permanently and removes sitemap settings from entity forms.

Parameters

string $entity_type_id:

Return value

\Drupal\simple_sitemap\Manager\EntityManager

File

src/Manager/EntityManager.php, line 113

Class

EntityManager
Class EntityManager

Namespace

Drupal\simple_sitemap\Manager

Code

public function disableEntityType(string $entity_type_id) : EntityManager {

  // Updating settings.
  $enabled_entity_types = $this->settings
    ->get('enabled_entity_types');
  if (FALSE !== ($key = array_search($entity_type_id, $enabled_entity_types, TRUE))) {
    unset($enabled_entity_types[$key]);
    $this->settings
      ->save('enabled_entity_types', array_values($enabled_entity_types));
  }

  // Deleting inclusion settings.
  foreach ($this->configFactory
    ->listAll('simple_sitemap.bundle_settings.') as $config_name) {
    if (explode('.', $config_name)[3] === $entity_type_id) {
      $this->configFactory
        ->getEditable($config_name)
        ->delete();
    }
  }

  // Deleting entity overrides.
  $this
    ->setVariants(TRUE)
    ->removeEntityInstanceSettings($entity_type_id);
  return $this;
}