Initial Drupal 11 with DDEV setup
This commit is contained in:
		
							
								
								
									
										97
									
								
								vendor/chi-teck/drupal-code-generator/templates/Plugin/Migrate/_destination/destination.twig
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								vendor/chi-teck/drupal-code-generator/templates/Plugin/Migrate/_destination/destination.twig
									
									
									
									
										vendored
									
									
										Normal 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.
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										69
									
								
								vendor/chi-teck/drupal-code-generator/templates/Plugin/Migrate/_process/process.twig
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								vendor/chi-teck/drupal-code-generator/templates/Plugin/Migrate/_process/process.twig
									
									
									
									
										vendored
									
									
										Normal 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;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										113
									
								
								vendor/chi-teck/drupal-code-generator/templates/Plugin/Migrate/_source/source.twig
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								vendor/chi-teck/drupal-code-generator/templates/Plugin/Migrate/_source/source.twig
									
									
									
									
										vendored
									
									
										Normal 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);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user