Chris@0: target_entity_type_id . '.' . $this->target_bundle; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getTargetEntityTypeId() { Chris@0: return $this->target_entity_type_id; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getTargetBundle() { Chris@0: return $this->target_bundle; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setTargetBundle($target_bundle) { Chris@0: $this->target_bundle = $target_bundle; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setDefaultLangcode($default_langcode) { Chris@0: $this->default_langcode = $default_langcode; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDefaultLangcode() { Chris@0: return $this->default_langcode; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function setLanguageAlterable($language_alterable) { Chris@0: $this->language_alterable = $language_alterable; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isLanguageAlterable() { Chris@0: return $this->language_alterable; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function preSave(EntityStorageInterface $storage) { Chris@0: $this->id = $this->id(); Chris@0: parent::preSave($storage); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function isDefaultConfiguration() { Chris@0: return (!$this->language_alterable && $this->default_langcode == LanguageInterface::LANGCODE_SITE_DEFAULT); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Loads a content language config entity based on the entity type and bundle. Chris@0: * Chris@0: * @param string $entity_type_id Chris@0: * ID of the entity type. Chris@0: * @param string $bundle Chris@0: * Bundle name. Chris@0: * Chris@0: * @return $this Chris@0: * The content language config entity if one exists. Otherwise, returns Chris@0: * default values. Chris@0: */ Chris@0: public static function loadByEntityTypeBundle($entity_type_id, $bundle) { Chris@0: if ($entity_type_id == NULL || $bundle == NULL) { Chris@0: return NULL; Chris@0: } Chris@0: $config = \Drupal::entityManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); Chris@0: if ($config == NULL) { Chris@0: $config = ContentLanguageSettings::create(['target_entity_type_id' => $entity_type_id, 'target_bundle' => $bundle]); Chris@0: } Chris@0: return $config; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function calculateDependencies() { Chris@0: parent::calculateDependencies(); Chris@0: Chris@0: // Create dependency on the bundle. Chris@0: $entity_type = \Drupal::entityManager()->getDefinition($this->target_entity_type_id); Chris@0: $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle); Chris@0: $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: }