-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from discoverygarden/feature/stomp-queue-update
DDST-136: Feature/stomp queue update
- Loading branch information
Showing
45 changed files
with
440 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# DGI Migrate Alter | ||
|
||
## Introduction | ||
A module to easily alter migrations using the `MigrationAlter` plugin. | ||
|
||
## Features | ||
The module adds the `MigrationAlter` plugin base, which allows for the easy alteration of migrations. | ||
|
||
The `MigrationAlter` plugin base has four fields: | ||
- `id` | ||
- `label` | ||
- `description` | ||
- `migration_id` | ||
- The id of the migration you wish to alter | ||
|
||
The path to place the alter plugins is as follows: | ||
- `module/Plugin/dgi_migrate_alter/spreadsheet` | ||
- `module/Plugin/dgi_migrate_alter/foxml` | ||
|
||
There is no strict difference between the two, and are pathed as such strictly for organization. | ||
|
||
The alter itself should be written in the `alter` function. | ||
|
||
## Installation | ||
|
||
Install as usual, see | ||
[this](https://drupal.org/documentation/install/modules-themes/modules-8) for | ||
further information. | ||
|
||
## Troubleshooting/Issues | ||
|
||
Having problems or solved a problem? Contact | ||
[discoverygarden](http://support.discoverygarden.ca). | ||
|
||
## Maintainers and Sponsors | ||
|
||
Current maintainers: | ||
|
||
* [discoverygarden](http://www.discoverygarden.ca) | ||
|
||
## Development/Contribution | ||
|
||
If you would like to contribute to this module, please check out github's helpful | ||
[Contributing to projects](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) documentation and Islandora community's [Documention for developers](https://islandora.github.io/documentation/contributing/CONTRIBUTING/#github-issues) to create an issue or pull request and/or | ||
contact [discoverygarden](http://support.discoverygarden.ca). | ||
|
||
## License | ||
|
||
[GPLv3](http://www.gnu.org/licenses/gpl-3.0.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: 'DGI Migrate Alter' | ||
description: "Allows easy alterations of migrations through plugins." | ||
type: module | ||
package: DGI | ||
core_version_requirement: ^9 || ^10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains dgi_migrate_alter.module. | ||
*/ | ||
|
||
use Drupal\dgi_migrate_alter\Exception\MigrationNotFoundException; | ||
|
||
/** | ||
* Implements hook_migration_plugins_alter(). | ||
*/ | ||
function dgi_migrate_alter_migration_plugins_alter(array &$migrations) { | ||
$logger = \Drupal::logger('dgi_migrate_alter'); | ||
|
||
$spreadsheet_alter_manager = \Drupal::service('plugin.manager.dgi_migrate_alter.spreadsheet'); | ||
$foxml_alter_manager = \Drupal::service('plugin.manager.dgi_migrate_alter.foxml'); | ||
|
||
$spreadsheet_definitions = $spreadsheet_alter_manager->getDefinitions(); | ||
$foxml_definitions = $foxml_alter_manager->getDefinitions(); | ||
|
||
foreach ($spreadsheet_definitions as $id => $definition) { | ||
$logger->info('Altering migrations with spreadsheet plugin: ' . $id); | ||
$plugin = $spreadsheet_alter_manager->createInstance($id); | ||
|
||
try { | ||
$plugin->alterMigrations($migrations); | ||
} | ||
catch (MigrationNotFoundException $e) { | ||
$logger->error('Migration not found: ' . $e->getMessage()); | ||
} | ||
} | ||
|
||
foreach ($foxml_definitions as $id => $definition) { | ||
$logger->info('Altering migrations with foxml plugin: ' . $id); | ||
$plugin = $foxml_alter_manager->createInstance($id); | ||
|
||
try { | ||
$plugin->alterMigrations($migrations); | ||
} | ||
catch (MigrationNotFoundException $e) { | ||
$logger->error('Migration not found: ' . $e->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
services: | ||
plugin.manager.dgi_migrate_alter.spreadsheet: | ||
class: Drupal\dgi_migrate_alter\Plugin\MigrationAlterPluginManager | ||
arguments: [spreadsheet, '@container.namespaces', '@cache.discovery', '@module_handler'] | ||
plugin.manager.dgi_migrate_alter.foxml: | ||
class: Drupal\dgi_migrate_alter\Plugin\MigrationAlterPluginManager | ||
arguments: [foxml, '@container.namespaces', '@cache.discovery', '@module_handler'] |
46 changes: 46 additions & 0 deletions
46
modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Drupal\dgi_migrate_alter\Annotation; | ||
|
||
use Drupal\Component\Annotation\Plugin; | ||
|
||
/** | ||
* Defines a MigrationAlter annotation object. | ||
* | ||
* @Annotation | ||
*/ | ||
class MigrationAlter extends Plugin { | ||
|
||
/** | ||
* The plugin ID. | ||
* | ||
* @var string | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* The human-readable name of the migration alteration. | ||
* | ||
* @var \Drupal\Core\Annotation\Translation | ||
* | ||
* @ingroup plugin_translatable | ||
*/ | ||
public $label; | ||
|
||
/** | ||
* The description of the migration alteration. | ||
* | ||
* @var \Drupal\Core\Annotation\Translation | ||
* | ||
* @ingroup plugin_translatable | ||
*/ | ||
public $description; | ||
|
||
/** | ||
* The migration ID. | ||
* | ||
* @var string | ||
*/ | ||
public $migration_id; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
modules/dgi_migrate_alter/src/Exception/MigrationNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Drupal\dgi_migrate_alter\Exception; | ||
|
||
/** | ||
* To throw when the Plugin Manager fails to find a migration to alter. | ||
*/ | ||
class MigrationNotFoundException extends \Exception {} |
39 changes: 39 additions & 0 deletions
39
modules/dgi_migrate_alter/src/Plugin/MigrationAlterBase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Drupal\dgi_migrate_alter\Plugin; | ||
|
||
use Drupal\Component\Plugin\PluginBase; | ||
use Drupal\dgi_migrate_alter\Exception\MigrationNotFoundException; | ||
|
||
/** | ||
* Base class for migration alter plugins. | ||
*/ | ||
abstract class MigrationAlterBase extends PluginBase implements MigrationAlterInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @throws \Drupal\dgi_migrate_alter\Exception\MigrationNotFoundException | ||
*/ | ||
final public function alterMigrations(array &$migrations) { | ||
$migration_id = $this->getPluginDefinition()['migration_id']; | ||
if (isset($migrations[$migration_id])) { | ||
$this->alter($migrations[$migration_id]); | ||
} | ||
else { | ||
throw new MigrationNotFoundException("Migration $migration_id not found."); | ||
} | ||
} | ||
|
||
/** | ||
* Alters the specified migration array provided by alterMigrations. | ||
* | ||
* This method is intended to be overridden in child classes. | ||
* Each child class should implement its own logic. | ||
* | ||
* @param array &$migration | ||
* The migration array to alter. | ||
*/ | ||
abstract protected function alter(array &$migration); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
modules/dgi_migrate_alter/src/Plugin/MigrationAlterInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Drupal\dgi_migrate_alter\Plugin; | ||
|
||
use Drupal\Component\Plugin\PluginInspectionInterface; | ||
|
||
/** | ||
* Interface for CSV Alteration plugins. | ||
*/ | ||
interface MigrationAlterInterface extends PluginInspectionInterface { | ||
|
||
/** | ||
* Alters the migrations. | ||
* | ||
* @param array $migrations | ||
* The migrations array. | ||
*/ | ||
public function alterMigrations(array &$migrations); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
modules/dgi_migrate_alter/src/Plugin/MigrationAlterPluginManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Drupal\dgi_migrate_alter\Plugin; | ||
|
||
use Drupal\Core\Cache\CacheBackendInterface; | ||
use Drupal\Core\Extension\ModuleHandlerInterface; | ||
use Drupal\Core\Plugin\DefaultPluginManager; | ||
|
||
/** | ||
* Provides the migration alter plugin manager. | ||
*/ | ||
class MigrationAlterPluginManager extends DefaultPluginManager { | ||
|
||
/** | ||
* Constructs a new MigrationAlterManager object. | ||
* | ||
* @param string $type | ||
* The type of the plugin: spreadsheet, foxml. | ||
* @param \Traversable $namespaces | ||
* An object that implements \Traversable which contains the root paths | ||
* keyed by the corresponding namespace to look for plugin implementations. | ||
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend | ||
* Cache backend instance to use. | ||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler | ||
* The module handler. | ||
*/ | ||
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { | ||
parent::__construct( | ||
"Plugin/dgi_migrate_alter/$type", | ||
$namespaces, | ||
$module_handler, | ||
'Drupal\dgi_migrate_alter\Plugin\MigrationAlterInterface', | ||
'Drupal\dgi_migrate_alter\Annotation\MigrationAlter' | ||
); | ||
$this->alterInfo('dgi_migrate_alter_' . $type . '_info'); | ||
$this->setCacheBackend($cache_backend, 'dgi_migrate_alter' . $type . '_plugins'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.