You are here

public function DomainStorage::create in Domain Access 8

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

domain/src/DomainStorage.php, line 154

Class

DomainStorage
Loads Domain records.

Namespace

Drupal\domain

Code

public function create(array $values = []) {
  $default = $this
    ->loadDefaultId();
  $domains = $this
    ->loadMultiple();
  if (empty($values)) {
    $values['hostname'] = $this
      ->createHostname();
    $values['name'] = \Drupal::config('system.site')
      ->get('name');
  }
  $values += [
    'scheme' => $this
      ->getDefaultScheme(),
    'status' => 1,
    'weight' => count($domains) + 1,
    'is_default' => (int) empty($default),
  ];
  $domain = parent::create($values);
  return $domain;
}