|
@@ -2,8 +2,9 @@
|
|
|
|
|
|
namespace Drupal\reinstall\Plugin\migrate\source;
|
|
|
|
|
|
+use Drupal\Core\Entity\EntityFieldManagerInterface;
|
|
|
+use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
|
|
|
use Drupal\migrate\Plugin\MigrationInterface;
|
|
|
-use Drupal\migrate\Row;
|
|
|
|
|
|
|
|
|
* Source plugin for terms from a YAML file.
|
|
@@ -13,6 +14,7 @@ use Drupal\migrate\Row;
|
|
|
* )
|
|
|
*/
|
|
|
class ReinstallFileSource extends SimpleSource {
|
|
|
+ const ENTITY_TYPE = 'file';
|
|
|
|
|
|
|
|
|
* Constructor.
|
|
@@ -21,48 +23,14 @@ class ReinstallFileSource extends SimpleSource {
|
|
|
array $configuration,
|
|
|
string $pluginId,
|
|
|
array $pluginDefinition,
|
|
|
- MigrationInterface $migration = NULL
|
|
|
+ MigrationInterface $migration,
|
|
|
+ EntityTypeBundleInfoInterface $ebi,
|
|
|
+ EntityFieldManagerInterface $efm
|
|
|
) {
|
|
|
- parent::__construct($configuration, $pluginId, $pluginDefinition, $migration);
|
|
|
- $this->records = array_map([$this, 'flattenRecord'], $this->initialParse($configuration));
|
|
|
- }
|
|
|
+ parent::__construct($configuration, $pluginId, $pluginDefinition, $migration, $ebi, $efm);
|
|
|
|
|
|
-
|
|
|
- * 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;
|
|
|
+ $rawRecords = array_map([$this, 'flattenRecord'], $this->initialParse($configuration));
|
|
|
+ $this->records = $rawRecords;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -74,6 +42,7 @@ class ReinstallFileSource extends SimpleSource {
|
|
|
'type' => 'integer',
|
|
|
],
|
|
|
];
|
|
|
+
|
|
|
return $ids;
|
|
|
}
|
|
|
|