You are here

public function Simplesitemap::getEntityInstanceSettings in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 8.2 src/Simplesitemap.php \Drupal\simple_sitemap\Simplesitemap::getEntityInstanceSettings()

Gets sitemap settings for an entity instance which overrides bundle settings, or gets bundle settings, if they are not overridden. This is done for the currently set variant. Please note, this method takes only the first set variant into account. See todo.

@todo multiple variants @todo: May want to use Simplesitemap::supplementDefaultSettings('entity', $settings) inside here instead of calling it everywhere this method is called.

Parameters

string $entity_type_id:

string $id:

Return value

array|false Array of entity instance settings or the settings of its bundle. False if entity type or variant does not exist.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/Simplesitemap.php, line 761

Class

Simplesitemap
Class Simplesitemap @package Drupal\simple_sitemap

Namespace

Drupal\simple_sitemap

Code

public function getEntityInstanceSettings($entity_type_id, $id) {
  if (empty($variants = $this
    ->getVariants(FALSE))) {
    return FALSE;
  }
  $results = $this->db
    ->select('simple_sitemap_entity_overrides', 'o')
    ->fields('o', [
    'inclusion_settings',
  ])
    ->condition('o.type', $variants[0])
    ->condition('o.entity_type', $entity_type_id)
    ->condition('o.entity_id', $id)
    ->execute()
    ->fetchField();
  if (!empty($results)) {
    return unserialize($results);
  }
  if (empty($entity = $this->entityTypeManager
    ->getStorage($entity_type_id)
    ->load($id))) {
    return FALSE;
  }
  return $this
    ->getBundleSettings($entity_type_id, $this->entityHelper
    ->getEntityInstanceBundleName($entity));
}