ContentEntityType.php in Drupal 9
File
core/lib/Drupal/Core/Entity/ContentEntityType.php
View source
<?php
namespace Drupal\Core\Entity;
class ContentEntityType extends EntityType implements ContentEntityTypeInterface {
protected $revision_metadata_keys = [];
public function __construct($definition) {
parent::__construct($definition);
$this->handlers += [
'storage' => 'Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage',
'view_builder' => 'Drupal\\Core\\Entity\\EntityViewBuilder',
];
$this->revision_metadata_keys += [
'revision_default' => 'revision_default',
];
}
public function getConfigDependencyKey() {
return 'content';
}
protected function checkStorageClass($class) {
$required_interface = ContentEntityStorageInterface::class;
if (!is_subclass_of($class, $required_interface)) {
throw new \InvalidArgumentException("{$class} does not implement {$required_interface}");
}
}
public function getRevisionMetadataKeys() {
return $this->revision_metadata_keys;
}
public function getRevisionMetadataKey($key) {
$keys = $this
->getRevisionMetadataKeys();
return isset($keys[$key]) ? $keys[$key] : FALSE;
}
public function hasRevisionMetadataKey($key) {
$keys = $this
->getRevisionMetadataKeys();
return isset($keys[$key]);
}
public function setRevisionMetadataKey($key, $field_name) {
if ($field_name !== NULL) {
$this->revision_metadata_keys[$key] = $field_name;
}
else {
unset($this->revision_metadata_keys[$key]);
}
return $this;
}
}