Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

[SDPA-1073] Added drush command to migrate site #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Post content to multiple sites and sections.
* Installation

# INTRODUCTION
The Tide Site module provides the functionality to post to multiple sites and sections from
a single content server.
The Tide Site module provides the functionality to post to multiple sites and
sections from a single content server.

# REQUIREMENTS
* [Tide Core](https://github.com/dpc-sdp/tide_core)
Expand All @@ -30,5 +30,6 @@ composer require dpc-sdp/tide_site

# Caveats

Tide Site is on the alpha release, use with caution. APIs are likely to change before the stable version, that there will be breaking changes and that we're not supporting it for external production sites at the moment.

Tide Site is on the alpha release, use with caution. APIs are likely to change
before the stable version, that there will be breaking changes and that we're
not supporting it for external production sites at the moment.
6 changes: 6 additions & 0 deletions drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
tide_site.commands:
class: \Drupal\tide_site\Commands\TideSiteCommands
arguments: ['@tide_site.migrator']
tags:
- { name: drush.command }
5 changes: 3 additions & 2 deletions scripts/composer/ScriptHandler.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace DrupalProject\composer;

/**
* @file
* Contains \DrupalProject\composer\ScriptHandler.
* @codingStandardsIgnoreStart
*/

namespace DrupalProject\composer;

use Composer\Script\Event;
use Composer\Semver\Comparator;
use DrupalFinder\DrupalFinder;
Expand Down
67 changes: 67 additions & 0 deletions src/Commands/TideSiteCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Drupal\tide_site\Commands;

/**
* @file
* Drush commands.
*/

use Drupal\tide_site\Migrator;
use Drush\Commands\DrushCommands;

/**
* Class TideSiteCommands.
*/
class TideSiteCommands extends DrushCommands {

/**
* The Migrator service.
*
* @var \Drupal\tide_site\Migrator
*/
protected $migrator;

/**
* TideSiteCommands constructor.
*
* @param \Drupal\tide_site\Migrator $migrator
* The migrator service.
*/
public function __construct(Migrator $migrator) {
$this->migrator = $migrator;
}

/**
* Move content from one Site to another Site.
*
* @param int $source_id
* Source Site ID.
* @param int $destination_id
* Destination Site ID.
*
* @command tide_site:migrate
* @aliases tide_site-migrate tsm
* @usage tide_site:migrate <SOURCE_ID> <DESTINATION_ID>
* Move content from site <SOURCE_ID> to <DESTINATION_ID>.
*/
public function migrate($source_id, $destination_id) {
try {
$batch = $this->migrator->getBatch($source_id, $destination_id);
if (!empty($batch)) {
batch_set($batch);
$batch =& batch_get();

// Because we are doing this on the back-end.
$batch['progressive'] = FALSE;

// Start processing the batch operations.
drush_backend_batch_process();
}
}
catch (\Exception $e) {
$this->output()->writeln($e->getMessage());
}
}

}
Loading