ConfigEntityType.php in Drupal 9
File
core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
View source
<?php
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException;
use Drupal\Core\Entity\EntityType;
use Drupal\Core\Config\ConfigPrefixLengthException;
class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
protected $config_prefix;
protected $static_cache = FALSE;
protected $lookup_keys = [];
protected $config_export = [];
protected $mergedConfigExport = [];
public function __construct($definition) {
if (empty($this->list_cache_tags)) {
$this->list_cache_tags = [
'config:' . $definition['id'] . '_list',
];
}
parent::__construct($definition);
$this->entity_keys['uuid'] = 'uuid';
$this->entity_keys['langcode'] = 'langcode';
$this->handlers += [
'storage' => 'Drupal\\Core\\Config\\Entity\\ConfigEntityStorage',
];
$this->lookup_keys[] = 'uuid';
}
public function getConfigPrefix() {
if (isset($this->config_prefix)) {
$config_prefix = $this->provider . '.' . $this->config_prefix;
}
else {
$config_prefix = $this->provider . '.' . $this
->id();
}
if (strlen($config_prefix) > static::PREFIX_LENGTH) {
throw new ConfigPrefixLengthException("The configuration file name prefix {$config_prefix} exceeds the maximum character limit of " . static::PREFIX_LENGTH);
}
return $config_prefix;
}
public function getBaseTable() {
return FALSE;
}
public function getRevisionDataTable() {
return FALSE;
}
public function getRevisionTable() {
return FALSE;
}
public function getDataTable() {
return FALSE;
}
public function getConfigDependencyKey() {
return 'config';
}
protected function checkStorageClass($class) {
if (!is_a($class, 'Drupal\\Core\\Config\\Entity\\ConfigEntityStorage', TRUE)) {
throw new ConfigEntityStorageClassException("{$class} is not \\Drupal\\Core\\Config\\Entity\\ConfigEntityStorage or it does not extend it");
}
}
public function getPropertiesToExport($id = NULL) {
if (!empty($this->mergedConfigExport)) {
return $this->mergedConfigExport;
}
if (!empty($this->config_export)) {
$this->mergedConfigExport = [
'uuid' => 'uuid',
'langcode' => 'langcode',
'status' => 'status',
'dependencies' => 'dependencies',
'third_party_settings' => 'third_party_settings',
'_core' => '_core',
];
foreach ($this->config_export as $property => $name) {
if (is_numeric($property)) {
$this->mergedConfigExport[$name] = $name;
}
else {
$this->mergedConfigExport[$property] = $name;
}
}
}
else {
return NULL;
}
return $this->mergedConfigExport;
}
public function getLookupKeys() {
return $this->lookup_keys;
}
}
Classes
Name |
Description |
ConfigEntityType |
Provides an implementation of a configuration entity type and its metadata. |