Initial Drupal 11 with DDEV setup

This commit is contained in:
gluebox
2025-10-08 11:39:17 -04:00
commit 89ef74b305
25344 changed files with 2599172 additions and 0 deletions

View File

@ -0,0 +1,97 @@
{% import '@lib/di.twig' as di %}
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Plugin\migrate\destination;
{% apply sort_namespaces %}
use Drupal\migrate\Attribute\MigrateDestination;
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
{% if services %}
{{ di.use(services) }}
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endapply %}
/**
* The '{{ plugin_id }}' destination plugin.
*/
#[MigrateDestination('{{ plugin_id }}')]
final class {{ class }} extends DestinationBase {% if services %}implements ContainerFactoryPluginInterface {% endif %}{
{% if services %}
/**
* Constructs the plugin instance.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
MigrationInterface $migration,
{{ di.signature(services) }}
) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
}
/**
* {@inheritdoc}
*/
public static function create(
ContainerInterface $container,
array $configuration,
$plugin_id,
$plugin_definition,
MigrationInterface $migration = NULL,
): self {
return new self(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
{{ di.container(services) }}
);
}
{% endif %}
/**
* {@inheritdoc}
*/
public function getIds(): array {
$ids['id']['type'] = [
'type' => 'integer',
'unsigned' => TRUE,
'size' => 'big',
];
return $ids;
}
/**
* {@inheritdoc}
*/
public function fields(?MigrationInterface $migration = NULL): array {
return [
'id' => $this->t('The row ID.'),
// @todo Describe row fields here.
];
}
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = []): array|bool {
// @todo Import the row here.
return [$row->getDestinationProperty('id')];
}
/**
* {@inheritdoc}
*/
public function rollback(array $destination_identifier): void {
// @todo Rollback the row here.
}
}

View File

@ -0,0 +1,69 @@
{% import '@lib/di.twig' as di %}
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Plugin\migrate\process;
{% apply sort_namespaces %}
use Drupal\migrate\Attribute\MigrateProcess;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
{% if services %}
{{ di.use(services) }}
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endapply %}
/**
* Provides {{ plugin_id|article }} plugin.
*
* Usage:
*
* @code
* process:
* bar:
* plugin: {{ plugin_id }}
* source: foo
* @endcode
*/
#[MigrateProcess('{{ plugin_id }}')]
final class {{ class }} extends ProcessPluginBase {% if services %}implements ContainerFactoryPluginInterface {% endif %}{
{% if services %}
/**
* Constructs the plugin instance.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
{{ di.signature(services) }}
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self {
return new self(
$configuration,
$plugin_id,
$plugin_definition,
{{ di.container(services) }}
);
}
{% endif %}
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property): mixed {
// @todo Transform the value here.
return $value;
}
}

View File

@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
namespace Drupal\{{ machine_name }}\Plugin\migrate\source;
{% if source_type == 'sql' %}
use Drupal\Core\Database\Query\SelectInterface;
{% endif %}
use Drupal\migrate\Plugin\migrate\source\{{ base_class }};
use Drupal\migrate\Row;
/**
* The '{{ plugin_id }}' source plugin.
*
* @MigrateSource(
* id = "{{ plugin_id }}",
* source_module = "{{ machine_name }}",
* )
*/
final class {{ class }} extends {{ base_class }} {
{% if source_type == 'sql' %}
/**
* {@inheritdoc}
*/
public function query(): SelectInterface {
return $this->select('example', 'e')
->fields('e', ['id', 'name', 'status']);
}
{% else %}
/**
* {@inheritdoc}
*/
public function __toString(): string {
// @DCG You may return something meaningful here.
return '';
}
/**
* {@inheritdoc}
*/
protected function initializeIterator(): \ArrayIterator {
// @DCG
// In this example we return a hardcoded set of records.
//
// For large sets of data consider using generators like follows:
// @code
// foreach ($foo->nextRecord() as $record) {
// yield $record;
// }
// @endcode
$records = [
[
'id' => 1,
'name' => 'Alpha',
'status' => TRUE,
],
[
'id' => 2,
'name' => 'Beta',
'status' => FALSE,
],
[
'id' => 3,
'name' => 'Gamma',
'status' => TRUE,
],
];
return new \ArrayIterator($records);
}
{% endif %}
/**
* {@inheritdoc}
*/
public function fields(): array {
return [
'id' => $this->t('The record ID.'),
'name' => $this->t('The record name.'),
'status' => $this->t('The record status'),
];
}
/**
* {@inheritdoc}
*/
public function getIds(): array {
$ids['id'] = [
'type' => 'integer',
'unsigned' => TRUE,
'size' => 'big',
];
return $ids;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row): bool {
// @DCG
// Modify the row here if needed.
// Example:
// @code
// $name = $row->getSourceProperty('name');
// $row->setSourceProperty('name', Html::escape('$name'));
// @endcode
return parent::prepareRow($row);
}
}