Initial Drupal 11 with DDEV setup
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\{{ machine_name }}\Plugin\EntityReferenceSelection;
|
||||
|
||||
{% apply sort_namespaces %}
|
||||
use Drupal\Core\Entity\Attribute\EntityReferenceSelection;
|
||||
use Drupal\Core\Entity\Query\QueryInterface;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
{% if configurable %}
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
{% endif %}
|
||||
use {{ base_class_full }}{% if base_class == class %} as Base{{ base_class }}{% endif %};
|
||||
{% endapply %}
|
||||
|
||||
/**
|
||||
* @todo Add plugin description here.
|
||||
*/
|
||||
#[EntityReferenceSelection(
|
||||
id: '{{ plugin_id }}',
|
||||
label: new TranslatableMarkup('{{ plugin_label }}'),
|
||||
group: '{{ plugin_id }}',
|
||||
weight: 1,
|
||||
entity_types: ['{{ entity_type }}'],
|
||||
)]
|
||||
final class {{ class }} extends {{ base_class == class ? 'Base' ~ base_class : base_class }} {
|
||||
|
||||
{% if configurable %}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration(): array {
|
||||
$default_configuration = [
|
||||
'foo' => 'bar',
|
||||
];
|
||||
return $default_configuration + parent::defaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state): array {
|
||||
$form = parent::buildConfigurationForm($form, $form_state);
|
||||
|
||||
$form['foo'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Foo'),
|
||||
'#default_value' => $this->configuration['foo'],
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS'): QueryInterface {
|
||||
$query = parent::buildEntityQuery($match, $match_operator);
|
||||
// @todo Modify the query here.
|
||||
return $query;
|
||||
}
|
||||
|
||||
}
|
||||
10
vendor/chi-teck/drupal-code-generator/templates/Plugin/_entity-reference-selection/schema.twig
vendored
Normal file
10
vendor/chi-teck/drupal-code-generator/templates/Plugin/_entity-reference-selection/schema.twig
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
entity_reference_selection.{{ plugin_id }}:
|
||||
{# User selection plugin provides has some additional options. #}
|
||||
type: entity_reference_selection.default{{ entity_type == 'user' ? ':user' }}
|
||||
label: '{{ plugin_label }} handler settings'
|
||||
{% if configurable %}
|
||||
mapping:
|
||||
foo:
|
||||
type: string
|
||||
label: Foo
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user