summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/path_alias/src/PathAliasStorage.php
blob: e2b98f9bcae3003f0e85b2443f8b417c06d8fc31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

namespace Drupal\path_alias;

use Drupal\Core\Entity\Sql\SqlContentEntityStorage;

/**
 * Defines the storage handler class for path_alias entities.
 */
class PathAliasStorage extends SqlContentEntityStorage {

  /**
   * {@inheritdoc}
   */
  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;
  }

}