devel_wizard-2.x-dev/templates/spell/entity_type/config/class.php.twig
templates/spell/entity_type/config/class.php.twig
{% set parentClass = 'ConfigEntityBundleBase' %}
{% if goal == 'config' %}
{%- set parentClass = 'ConfigEntityBase' %}
{% endif %}
{% set parentFqn = 'Drupal\\Core\\Config\\Entity\\' ~ parentClass %}
{%-
include '@devel_wizard/php/devel_wizard.php.file.header.php.twig'
with {
'namespace': module.namespace ~ '\\Entity',
}
%}
use {{ config.interface_fqn ~}};
use {{ parentFqn }};
/**
* @ConfigEntityType(
* id = "{{ config.id }}",
{% if goal == 'bundleable' %}
* bundle_of = "{{ content.id }}",
{% endif %}
* label = @Translation("{{ config.label }}"),
* label_collection = @Translation("{{ config.label }}"),
* label_singular = @Translation("{{ config.label }}"),
* label_plural = @Translation("{{ config.label_plural }}"),
* label_count = @PluralTranslation(
* singular = "@count {{ config.label }}",
* plural = "@count {{ config.label_plural }}",
* ),
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "weight" = "weight",
* },
* handlers = {
* "storage" = "{{ config.namespace }}\Storage",
* "access" = "{{ config.namespace }}\AccessControlHandler",
* "list_builder" = "{{ config.namespace }}\ListBuilder",
* "form" = {
* "default" = "{{ config.namespace }}\AddForm",
* "add" = "{{ config.namespace }}\AddForm",
* "edit" = "{{ config.namespace }}\EditForm",
* "delete" = "{{ config.namespace }}\DeleteForm",
* },
* "route_provider" = {
* "html" = "{{ config.namespace }}\RouteProvider",
* }
* },
* links = {
* "add-form" = "/admin/structure/{{ config.id }}/add",
* "edit-form" = "/admin/structure/{{ config.id }}/manage/{{ '{' }}{{ config.id }}{{ '}' }}",
* "delete-form" = "/admin/structure/{{ config.id }}/manage/{{ '{' }}{{ config.id }}{{ '}' }}/delete",
* "collection" = "/admin/structure/{{ config.id }}"
* },
* admin_permission = "{{ module.machineName }}.{{ config.id }}.admin",
* config_prefix = "{{ config.id }}",
* config_export = {
* "id",
* "label",
* "description",
* "help",
* "weight",
* }
* )
*/
class {{ config.class }} extends {{ parentClass }} implements {{ config.interface }} {
protected string $help = '';
public function getHelp(): string {
return $this->help;
}
protected string $description = '';
/**
* {@inheritdoc}
*/
public function getDescription(): string {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function setDescription($description) {
$this->description = $description;
return $this;
}
protected int $weight;
public function getWeight(): int {
return $this->weight;
}
public function setWeight(int $weight): static {
$this->weight = $weight;
return $this;
}
{%- if goal == 'bundleable' ~%}
protected bool $createNewRevision = FALSE;
public function shouldCreateNewRevision(): bool {
return $this->createNewRevision;
}
{%- endif ~%}
}
