123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?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_files"
- * )
- */
- class ReinstallFileSource extends SimpleSource {
- /**
- * Constructor.
- */
- public function __construct(
- array $configuration,
- string $pluginId,
- array $pluginDefinition,
- MigrationInterface $migration = NULL
- ) {
- parent::__construct($configuration, $pluginId, $pluginDefinition, $migration);
- $this->records = array_map([$this, 'flattenRecord'], $this->initialParse($configuration));
- }
- protected function flattenRecord($record) {
- $row = new Row($record);
- $this->flattenRow($row);
- return $row->getSource();
- }
- /**
- * {@inheritdoc}
- */
- public function fields() {
- $ret = [
- 'fid' => 'File ID',
- 'uid' => 'User ID',
- 'uuid' => 'UUID',
- 'langcode' => 'ISO 639 language code',
- 'filename' => 'File name without directory',
- 'uri' => 'File URI, like public://foo.png',
- 'filemime' => 'Mime type per https://www.iana.org/assignments/media-types/media-types.xhtml',
- 'filesize' => 'File size, in bytes',
- 'status' => 'File status (temporary or permanent)',
- 'created' => 'Creation timestamp',
- 'changed' => 'Modification timestamp',
- ];
- return $ret;
- }
- /**
- * {@inheritdoc}
- */
- public function getIds() {
- $ids = [
- 'fid' => [
- 'type' => 'integer',
- ],
- ];
- return $ids;
- }
- }
|