checked files and taxo migration, added migrate shell script, started managing admin UI

This commit is contained in:
2019-02-04 11:24:31 +01:00
parent f45a235fa6
commit 2ed361dd35
25 changed files with 238 additions and 40 deletions

View File

@@ -8,7 +8,7 @@ migration_tags:
- Drupal 7
- Content
source:
plugin: d7_file
plugin: d7_pubic_file
scheme: public
constants:
# The tool configuring this migration must set source_base_path. It
@@ -19,7 +19,7 @@ source:
process:
# If you are using this file to build a custom migration consider removing
# the fid field to allow incremental migrations.
fid: fid
# fid: fid
filename: filename
source_full_path:
-

View File

@@ -81,7 +81,7 @@ class D7NodeBreve extends FieldableEntity {
'log',
'timestamp',
])
->orderBy('nid');
->orderBy('changed');
$query->addField('n', 'uid', 'node_uid');
$query->addField('nr', 'uid', 'revision_uid');
@@ -99,6 +99,12 @@ class D7NodeBreve extends FieldableEntity {
$query->condition('n.type', $this->configuration['node_type']);
}
$this->highwaterField = array(
'name' => 'changed',
'alias' => 'n',
'type' => 'int',
);
return $query;
}

View File

@@ -36,13 +36,15 @@ class D7NodeBreveI18n extends FieldableEntity {
'type',
'promote',
'sticky',
'changed',
])
->fields('nr', [
'log',
'timestamp',
])
->condition('et.entity_type', 'node')
->condition('et.source', '', '<>');
->condition('et.source', '', '<>')
->orderBy('changed');
$query->addField('nr', 'uid', 'revision_uid');
@@ -53,6 +55,12 @@ class D7NodeBreveI18n extends FieldableEntity {
$query->condition('n.type', $this->configuration['node_type']);
}
$this->highwaterField = array(
'name' => 'changed',
'alias' => 'n',
'type' => 'int',
);
return $query;
}

View File

@@ -0,0 +1,119 @@
<?php
namespace Drupal\materio_migrate\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 file source from database.
*
* @MigrateSource(
* id = "d7_pubic_file",
* source_module = "file"
* )
*/
class D7PublicFile extends DrupalSqlBase {
/**
* The public file directory path.
*
* @var string
*/
protected $publicPath;
/**
* The private file directory path, if any.
*
* @var string
*/
protected $privatePath;
/**
* The temporary file directory path.
*
* @var string
*/
protected $temporaryPath;
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('file_managed', 'f')
->fields('f')
->condition('uri', 'temporary://%', 'NOT LIKE')
->orderBy('f.timestamp');
// Filter by scheme(s), if configured.
if (isset($this->configuration['scheme'])) {
$schemes = [];
// Remove 'temporary' scheme.
$valid_schemes = array_diff((array) $this->configuration['scheme'], ['temporary']);
// Accept either a single scheme, or a list.
foreach ((array) $valid_schemes as $scheme) {
$schemes[] = rtrim($scheme) . '://';
}
$schemes = array_map([$this->getDatabase(), 'escapeLike'], $schemes);
// Add conditions, uri LIKE 'public://%' OR uri LIKE 'private://%'.
$conditions = new Condition('OR');
foreach ($schemes as $scheme) {
$conditions->condition('uri', $scheme . '%', 'LIKE');
}
$query->condition($conditions);
}
return $query;
}
/**
* {@inheritdoc}
*/
protected function initializeIterator() {
$this->publicPath = $this->variableGet('file_public_path', 'sites/default/files');
$this->privatePath = $this->variableGet('file_private_path', NULL);
$this->temporaryPath = $this->variableGet('file_temporary_path', '/tmp');
return parent::initializeIterator();
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Compute the filepath property, which is a physical representation of
// the URI relative to the Drupal root.
$path = str_replace(['public:/', 'private:/', 'temporary:/'], [$this->publicPath, $this->privatePath, $this->temporaryPath], $row->getSourceProperty('uri'));
// At this point, $path could be an absolute path or a relative path,
// depending on how the scheme's variable was set. So we need to shear out
// the source_base_path in order to make them all relative.
$path = str_replace($this->configuration['constants']['source_base_path'], NULL, $path);
$row->setSourceProperty('filepath', $path);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'fid' => $this->t('File ID'),
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
'filename' => $this->t('File name'),
'filepath' => $this->t('File path'),
'filemime' => $this->t('File MIME Type'),
'status' => $this->t('The published status of a file.'),
'timestamp' => $this->t('The time that the file was added.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['fid']['type'] = 'integer';
return $ids;
}
}

View File

@@ -104,7 +104,7 @@ class D7TaxonomyTermShowroom extends FieldableEntity {
public function prepareRow(Row $row) {
$language = $row->getSourceProperty('language');
$tid = $row->getSourceProperty('tid');
drush_print('-- '.$language."\t".$tid."\t".$row->getSourceProperty('name'));
// drush_print('-- '.$language."\t".$tid."\t".$row->getSourceProperty('name'));
// vocabulary machine name
$machine_name = $row->getSourceProperty('machine_name');

View File

@@ -66,7 +66,7 @@ class D7TaxonomyTermTags extends FieldableEntity {
*/
public function prepareRow(Row $row) {
$language = $row->getSourceProperty('language');
drush_print('-- '.$language."\t".$row->getSourceProperty('tid')."\t".$row->getSourceProperty('name'));
// drush_print('-- '.$language."\t".$row->getSourceProperty('tid')."\t".$row->getSourceProperty('name'));
$tid = $row->getSourceProperty('tid');
// vocabulary machine name

View File

@@ -64,7 +64,7 @@ class D7TaxonomyTermTagsI18n extends FieldableEntity {
$language = $row->getSourceProperty('language');
$tid = $row->getSourceProperty('tid');
drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name'));
// drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name'));
// vocabulary machine name
$machine_name = $row->getSourceProperty('machine_name');

View File

@@ -66,7 +66,7 @@ class D7TaxonomyTermThesaurus extends FieldableEntity {
*/
public function prepareRow(Row $row) {
$language = $row->getSourceProperty('language');
drush_print('-- '.$language."\t".$row->getSourceProperty('tid')."\t".$row->getSourceProperty('name'));
// drush_print('-- '.$language."\t".$row->getSourceProperty('tid')."\t".$row->getSourceProperty('name'));
$tid = $row->getSourceProperty('tid');
// vocabulary machine name

View File

@@ -64,7 +64,7 @@ class D7TaxonomyTermThesaurusI18n extends FieldableEntity {
$language = $row->getSourceProperty('language');
$tid = $row->getSourceProperty('tid');
drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name'));
// drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name'));
// vocabulary machine name
$machine_name = $row->getSourceProperty('machine_name');