function LocaleTranslatableProject::__construct

Locale translatable project value object.

Parameters

string $name: The project name.

string $type: The extension type.

string $core: The core version constraint.

string $version: The project's version.

string $server_pattern: The server pattern.

array $info: The .info.yml parsed project information.

string|null $langcode: The language code.

int $weight: Allows to order the projects.

bool $status: Whether the project is enabled.

File

core/modules/locale/src/LocaleTranslatableProject.php, line 34

Class

LocaleTranslatableProject
Translatable project for interface translation.

Namespace

Drupal\locale

Code

public function __construct(public string $name, public string $type, public string $core, public string $version, public string $server_pattern, public array $info = [], public ?string $langcode = NULL, protected int $weight = 0, protected bool $status = FALSE) {
  $emptyParameters = [];
  foreach ([
    'name',
    'type',
    'core',
    'server_pattern',
  ] as $property) {
    if (empty(trim(${$property}))) {
      $emptyParameters[] = '$' . $property;
    }
  }
  if ($emptyParameters) {
    throw new \InvalidArgumentException('The following parameters are empty: ' . implode(', ', $emptyParameters));
  }
}

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