You are here

public function EventType::calculateDependencies in RNG - Events and Registrations 8

Calculates dependencies and stores them in the dependency property.

Return value

$this

Overrides ConfigEntityBase::calculateDependencies

See also

\Drupal\Core\Config\Entity\ConfigDependencyManager

File

src/Entity/EventType.php, line 452

Class

EventType
Defines the event type entity.

Namespace

Drupal\rng\Entity

Code

public function calculateDependencies() {
  parent::calculateDependencies();

  // Event entity type/bundle.
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($this
    ->getEventEntityTypeId());
  if ($entity_type) {
    $bundle_entity_type = $entity_type
      ->getBundleEntityType();
    if ($bundle_entity_type && $bundle_entity_type !== 'bundle') {
      $bundle = \Drupal::entityTypeManager()
        ->getStorage($entity_type
        ->getBundleEntityType())
        ->load($this
        ->getEventBundle());
      if ($bundle) {
        $this
          ->addDependency('config', $bundle
          ->getConfigDependencyName());
      }
    }
    else {
      $this
        ->addDependency('module', $entity_type
        ->getProvider());
    }
  }

  // Default registrant type.
  $registrant_type_id = $this
    ->getDefaultRegistrantType();
  if ($registrant_type_id) {
    $registrant_type = RegistrantType::load($registrant_type_id);
    if ($registrant_type) {
      $this
        ->addDependency('config', $registrant_type
        ->getConfigDependencyName());
    }
  }
  return $this;
}