function ComponentMetadata::__construct
Same name in this branch
- 11.x core/lib/Drupal/Core/Theme/Component/ComponentMetadata.php \Drupal\Core\Theme\Component\ComponentMetadata::__construct()
Same name in other branches
- 10 core/modules/sdc/src/Component/ComponentMetadata.php \Drupal\sdc\Component\ComponentMetadata::__construct()
- 10 core/lib/Drupal/Core/Theme/Component/ComponentMetadata.php \Drupal\Core\Theme\Component\ComponentMetadata::__construct()
ComponentMetadata constructor.
Parameters
array $metadata_info: The metadata info.
string $app_root: The application root.
bool $enforce_schemas: Enforces the definition of schemas for props and slots.
Throws
\Drupal\sdc\Exception\InvalidComponentException
File
-
core/
modules/ sdc/ src/ Component/ ComponentMetadata.php, line 108
Class
- ComponentMetadata
- Component metadata.
Namespace
Drupal\sdc\ComponentCode
public function __construct(array $metadata_info, string $app_root, bool $enforce_schemas) {
$path = $metadata_info['path'];
// Make the absolute path, relative to the Drupal root.
$app_root = rtrim($app_root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if (str_starts_with($path, $app_root)) {
$path = substr($path, strlen($app_root));
}
$this->mandatorySchemas = $enforce_schemas;
$this->path = $path;
[
,
$machine_name,
] = explode(':', $metadata_info['id'] ?? []);
$this->machineName = $machine_name;
$this->name = $metadata_info['name'] ?? mb_convert_case($machine_name, MB_CASE_TITLE);
$this->description = $metadata_info['description'] ?? $this->t('- Description not available -');
$this->status = ExtensionLifecycle::isValid($metadata_info['status'] ?? '') ? $metadata_info['status'] : ExtensionLifecycle::STABLE;
$this->documentation = $metadata_info['documentation'] ?? '';
$this->group = $metadata_info['group'] ?? $this->t('All Components');
// Save the schemas.
$this->parseSchemaInfo($metadata_info);
$this->slots = $metadata_info['slots'] ?? [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.