1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?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));
- }
- /**
- * Flatten the field hierarchy. Not correct for all cases.
- *
- * @param array $record
- * The raw source values.
- *
- * @return array
- * The flattened values.
- *
- * @see \Drupal\reinstall\Plugin\migrate\process\TermParent
- */
- protected function flattenRecord(array $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;
- }
- }
|