public function NeutralPathAliasStorage::save in Language neutral aliases 8.2
Same name and namespace in other branches
- 3.x src/NeutralPathAliasStorage.php \Drupal\language_neutral_aliases\NeutralPathAliasStorage::save()
Saves the entity permanently.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
Return value
SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.
Overrides SqlContentEntityStorage::save
File
- src/
NeutralPathAliasStorage.php, line 30
Class
- NeutralPathAliasStorage
- Extend PathAliasStorage to save aliases with neutral language.
Namespace
Drupal\language_neutral_aliasesCode
public function save(EntityInterface $entity) {
$langKey = $entity
->getEntityType()
->getKey('langcode');
if ($langKey && $entity->{$langKey} != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
$entity->{$langKey} = LanguageInterface::LANGCODE_NOT_SPECIFIED;
}
return parent::save($entity);
}