Skip to content

Commit

Permalink
Add stream wrapper for migration source files.
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Borchert <[email protected]>
  • Loading branch information
Stefan Borchert committed Jul 1, 2017
1 parent 68532fa commit 74d3f92
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ Example for definition in custom source plugin (must extend `SqlBase`)
*/

For more complex ID definitions simply override the function `getIds()`.

### Stream wrapper

_up_migrate_ provides a custom read-only stream wrapper to access files needed
for migrations in a handy way.

To setup the correct directoy to your migration files, add the following code to
your _settings.php_

// Set private folder.
$settings['file_migration_source_path'] = '/path/to/migration/files';
51 changes: 51 additions & 0 deletions src/StreamWrapper/MigrationStream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Drupal\up_migrate\StreamWrapper;

use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\LocalReadOnlyStream;

/**
* Simple read-only stream wrapper for migration files.
*/
class MigrationStream extends LocalReadOnlyStream {

/**
* {@inheritdoc}
*/
public function getName() {
return t('Migration source files');
}

/**
* {@inheritdoc}
*/
public function getDescription() {
return t('Migration files');
}

/**
* {@inheritdoc}
*/
public function getDirectoryPath() {
return static::basePath();
}

/**
* {@inheritdoc}
*/
public function getExternalUrl() {
throw new \LogicException('Migration file URLs are not meant to be public.');
}

/**
* Returns the base path for migration:https://.
*
* @return string
* The base path for migration:https://.
*/
public static function basePath() {
return Settings::get('file_migration_source_path');
}

}

0 comments on commit 74d3f92

Please sign in to comment.