You are here

public function NeutralPathAliasStorage::create in Language neutral aliases 8.2

Same name and namespace in other branches
  1. 3.x src/NeutralPathAliasStorage.php \Drupal\language_neutral_aliases\NeutralPathAliasStorage::create()

Constructs a new entity object, without permanently saving it.

Parameters

array $values: (optional) An array of values to set, keyed by property name. If the entity type has bundles, the bundle key has to be specified.

Return value

\Drupal\Core\Entity\EntityInterface A new entity object.

Overrides EntityStorageBase::create

File

src/NeutralPathAliasStorage.php, line 17

Class

NeutralPathAliasStorage
Extend PathAliasStorage to save aliases with neutral language.

Namespace

Drupal\language_neutral_aliases

Code

public function create(array $values = []) {
  $entity = parent::create($values);
  $langKey = $entity
    ->getEntityType()
    ->getKey('langcode');
  $entity->{$langKey} = LanguageInterface::LANGCODE_NOT_SPECIFIED;
  return $entity;
}