target_entity_type_id . '.' . $this->target_bundle; } /** * {@inheritdoc} */ public function getTargetEntityTypeId() { return $this->target_entity_type_id; } /** * {@inheritdoc} */ public function getTargetBundle() { return $this->target_bundle; } /** * {@inheritdoc} */ public function setTargetBundle($target_bundle) { $this->target_bundle = $target_bundle; return $this; } /** * {@inheritdoc} */ public function setDefaultLangcode($default_langcode) { $this->default_langcode = $default_langcode; return $this; } /** * {@inheritdoc} */ public function getDefaultLangcode() { return $this->default_langcode; } /** * {@inheritdoc} */ public function setLanguageAlterable($language_alterable) { $this->language_alterable = $language_alterable; return $this; } /** * {@inheritdoc} */ public function isLanguageAlterable() { return $this->language_alterable; } /** * {@inheritdoc} */ public function preSave(EntityStorageInterface $storage) { $this->id = $this->id(); parent::preSave($storage); } /** * {@inheritdoc} */ public function isDefaultConfiguration() { return (!$this->language_alterable && $this->default_langcode == LanguageInterface::LANGCODE_SITE_DEFAULT); } /** * Loads a content language config entity based on the entity type and bundle. * * @param string $entity_type_id * ID of the entity type. * @param string $bundle * Bundle name. * * @return $this * The content language config entity if one exists. Otherwise, returns * default values. */ public static function loadByEntityTypeBundle($entity_type_id, $bundle) { if ($entity_type_id == NULL || $bundle == NULL) { return NULL; } $config = \Drupal::entityManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); if ($config == NULL) { $config = ContentLanguageSettings::create(['target_entity_type_id' => $entity_type_id, 'target_bundle' => $bundle]); } return $config; } /** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $bundle_entity_type_id = $this->entityManager()->getDefinition($this->target_entity_type_id)->getBundleEntityType(); if ($bundle_entity_type_id != 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle)) { throw new \LogicException("Missing bundle entity, entity type $bundle_entity_type_id, entity id {$this->target_bundle}."); } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } return $this->dependencies; } }