1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace Drupal\reinstall\Plugin\migrate\source;
- use Drupal\migrate\Plugin\MigrationInterface;
- use Drupal\migrate\Row;
- /**
- * Source plugin for terms from a YAML file.
- *
- * @MigrateSource(
- * id = "reinstall_terms"
- * )
- */
- class ReinstallTermSource extends SimpleSource {
- /**
- * Constructor.
- */
- public function __construct(
- array $configuration,
- string $pluginId,
- array $pluginDefinition,
- MigrationInterface $migration
- ) {
- parent::__construct($configuration, $pluginId, $pluginDefinition, $migration);
- $rawRecords = array_map([$this, 'flattenRecord'], $this->initialParse($configuration));
- $this->records = $rawRecords;
- }
- protected function flattenRecord($record) {
- $row = new Row($record);
- $this->flattenRow($row);
- return $row->getSource();
- }
- /**
- * {@inheritdoc}
- */
- public function fields() {
- $ret = [
- 'changed' => 'Modification timestamp',
- 'default_langcode' => 'ISO 639 default language code',
- 'description' => 'The entity description',
- 'langcode' => 'ISO 639 language code',
- 'name' => 'The term name (PK)',
- 'parent' => 'Parent term ID',
- 'path' => 'Optional path alias',
- 'tid' => 'Taxonomy term ID',
- 'uuid' => 'UUID',
- 'vid' => 'Vocabulary ID',
- 'weight' => 'Poids',
- ];
- return $ret;
- }
- /**
- * {@inheritdoc}
- */
- public function getIds() {
- $ids = [
- 'tid' => [
- 'type' => 'integer',
- ],
- ];
- return $ids;
- }
- }
|