function PathAliasStorage::createWithSampleValues

Same name in other branches
  1. 8.9.x core/modules/path_alias/src/PathAliasStorage.php \Drupal\path_alias\PathAliasStorage::createWithSampleValues()
  2. 10 core/modules/path_alias/src/PathAliasStorage.php \Drupal\path_alias\PathAliasStorage::createWithSampleValues()
  3. 11.x core/modules/path_alias/src/PathAliasStorage.php \Drupal\path_alias\PathAliasStorage::createWithSampleValues()

Overrides ContentEntityStorageBase::createWithSampleValues

File

core/modules/path_alias/src/PathAliasStorage.php, line 15

Class

PathAliasStorage
Defines the storage handler class for path_alias entities.

Namespace

Drupal\path_alias

Code

public function createWithSampleValues($bundle = FALSE, array $values = []) {
    $entity = parent::createWithSampleValues($bundle, [
        'path' => '/<front>',
    ] + $values);
    // Ensure the alias is only 255 characters long.
    $entity->set('alias', substr('/' . $entity->get('alias')->value, 0, 255));
    return $entity;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.