Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,60 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateMessageInterface;
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
class EventBase extends SymfonyEvent {
/**
* The migration.
*
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* The current message service.
*
* @var \Drupal\migrate\MigrateMessageInterface
*/
protected $message;
/**
* Constructs a Migrate event object.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration being run.
* @param \Drupal\migrate\MigrateMessageInterface $message
* The Migrate message service.
*/
public function __construct(MigrationInterface $migration, MigrateMessageInterface $message) {
$this->migration = $migration;
$this->message = $message;
}
/**
* Gets the migration.
*
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration being run.
*/
public function getMigration() {
return $this->migration;
}
/**
* Logs a message using the Migrate message service.
*
* @param string $message
* The message to log.
* @param string $type
* The type of message, for example: status or warning.
*/
public function logMessage($message, $type = 'status') {
$this->message->display($message, $type);
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace Drupal\migrate\Event;
/**
* Interface for plugins that react to pre- or post-import events.
*/
interface ImportAwareInterface {
/**
* Performs pre-import tasks.
*
* @param \Drupal\migrate\Event\MigrateImportEvent $event
* The pre-import event object.
*/
public function preImport(MigrateImportEvent $event);
/**
* Performs post-import tasks.
*
* @param \Drupal\migrate\Event\MigrateImportEvent $event
* The post-import event object.
*/
public function postImport(MigrateImportEvent $event);
}

View file

@ -0,0 +1,184 @@
<?php
namespace Drupal\migrate\Event;
/**
* Defines events for the migration system.
*
* @see \Drupal\migrate\Event\MigrateMapSaveEvent
* @see \Drupal\migrate\Event\MigrateMapDeleteEvent
* @see \Drupal\migrate\Event\MigrateImportEvent
* @see \Drupal\migrate\Event\MigratePreRowSaveEvent
* @see \Drupal\migrate\Event\MigratePostRowSaveEvent
* @see \Drupal\migrate\Event\MigrateRollbackEvent
* @see \Drupal\migrate\Event\MigrateRowDeleteEvent
* @see \Drupal\migrate\Event\MigrateIdMapMessageEvent
*/
final class MigrateEvents {
/**
* Name of the event fired when saving to a migration's map.
*
* This event allows modules to perform an action whenever the disposition of
* an item being migrated is saved to the map table. The event listener method
* receives a \Drupal\migrate\Event\MigrateMapSaveEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateMapSaveEvent
*
* @var string
*/
const MAP_SAVE = 'migrate.map_save';
/**
* Name of the event fired when removing an entry from a migration's map.
*
* This event allows modules to perform an action whenever a row is deleted
* from a migration's map table (implying it has been rolled back). The event
* listener method receives a \Drupal\migrate\Event\MigrateMapDeleteEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateMapDeleteEvent
*
* @var string
*/
const MAP_DELETE = 'migrate.map_delete';
/**
* Name of the event fired when beginning a migration import operation.
*
* This event allows modules to perform an action whenever a migration import
* operation is about to begin. The event listener method receives a
* \Drupal\migrate\Event\MigrateImportEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateImportEvent
*
* @var string
*/
const PRE_IMPORT = 'migrate.pre_import';
/**
* Name of the event fired when finishing a migration import operation.
*
* This event allows modules to perform an action whenever a migration import
* operation is completing. The event listener method receives a
* \Drupal\migrate\Event\MigrateImportEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateImportEvent
*
* @var string
*/
const POST_IMPORT = 'migrate.post_import';
/**
* Name of the event fired when about to import a single item.
*
* This event allows modules to perform an action whenever a specific item
* is about to be saved by the destination plugin. The event listener method
* receives a \Drupal\migrate\Event\MigratePreRowSaveEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigratePreRowSaveEvent
*
* @var string
*/
const PRE_ROW_SAVE = 'migrate.pre_row_save';
/**
* Name of the event fired just after a single item has been imported.
*
* This event allows modules to perform an action whenever a specific item
* has been saved by the destination plugin. The event listener method
* receives a \Drupal\migrate\Event\MigratePostRowSaveEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigratePostRowSaveEvent
*
* @var string
*/
const POST_ROW_SAVE = 'migrate.post_row_save';
/**
* Name of the event fired when beginning a migration rollback operation.
*
* This event allows modules to perform an action whenever a migration
* rollback operation is about to begin. The event listener method receives a
* \Drupal\migrate\Event\MigrateRollbackEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateRollbackEvent
*
* @var string
*/
const PRE_ROLLBACK = 'migrate.pre_rollback';
/**
* Name of the event fired when finishing a migration rollback operation.
*
* This event allows modules to perform an action whenever a migration
* rollback operation is completing. The event listener method receives a
* \Drupal\migrate\Event\MigrateRollbackEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateRollbackEvent
*
* @var string
*/
const POST_ROLLBACK = 'migrate.post_rollback';
/**
* Name of the event fired when about to delete a single item.
*
* This event allows modules to perform an action whenever a specific item
* is about to be deleted by the destination plugin. The event listener method
* receives a \Drupal\migrate\Event\MigrateRowDeleteEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateRowDeleteEvent
*
* @var string
*/
const PRE_ROW_DELETE = 'migrate.pre_row_delete';
/**
* Name of the event fired just after a single item has been deleted.
*
* This event allows modules to perform an action whenever a specific item
* has been deleted by the destination plugin. The event listener method
* receives a \Drupal\migrate\Event\MigrateRowDeleteEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateRowDeleteEvent
*
* @var string
*/
const POST_ROW_DELETE = 'migrate.post_row_delete';
/**
* Name of the event fired when saving a message to the idmap.
*
* This event allows modules to perform an action whenever a message is being
* logged by the idmap. The event listener method
* receives a \Drupal\migrate\Event\MigrateIdMapMessageEvent instance.
*
* @Event
*
* @see \Drupal\migrate\Event\MigrateIdMapMessageEvent
*
* @var string
*/
const IDMAP_MESSAGE = 'migrate.idmap_message';
}

View file

@ -0,0 +1,101 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Wraps an idmap message event for event listeners.
*/
class MigrateIdMapMessageEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Array of values uniquely identifying the source row.
*
* @var array
*/
protected $sourceIdValues;
/**
* Message to be logged.
*
* @var string
*/
protected $message;
/**
* Message severity.
*
* @var int
*/
protected $level;
/**
* Constructs a post-save event object.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param array $source_id_values
* Values represent the source ID.
* @param string $message
* The message
* @param int $level
* Severity level (one of the MigrationInterface::MESSAGE_* constants).
*/
public function __construct(MigrationInterface $migration, array $source_id_values, $message, $level) {
$this->migration = $migration;
$this->sourceIdValues = $source_id_values;
$this->message = $message;
$this->level = $level;
}
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration entity involved.
*/
public function getMigration() {
return $this->migration;
}
/**
* Gets the source ID values.
*
* @return array
* The source ID as an array.
*/
public function getSourceIdValues() {
return $this->sourceIdValues;
}
/**
* Gets the message to be logged.
*
* @return string
* The message text.
*/
public function getMessage() {
return $this->message;
}
/**
* Gets the severity level of the message (one of the
* MigrationInterface::MESSAGE_* constants).
*
* @return int
* The message level.
*/
public function getLevel() {
return $this->level;
}
}

View file

@ -0,0 +1,8 @@
<?php
namespace Drupal\migrate\Event;
/**
* Wraps a pre- or post-import event for event listeners.
*/
class MigrateImportEvent extends EventBase {}

View file

@ -0,0 +1,60 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Wraps a migrate map delete event for event listeners.
*/
class MigrateMapDeleteEvent extends Event {
/**
* Map plugin.
*
* @var \Drupal\migrate\Plugin\MigrateIdMapInterface
*/
protected $map;
/**
* Array of source ID fields.
*
* @var array
*/
protected $sourceId;
/**
* Constructs a migration map delete event object.
*
* @param \Drupal\migrate\Plugin\MigrateIdMapInterface $map
* Map plugin.
* @param array $source_id
* Array of source ID fields representing the object being deleted from the map.
*/
public function __construct(MigrateIdMapInterface $map, array $source_id) {
$this->map = $map;
$this->sourceId = $source_id;
}
/**
* Gets the map plugin.
*
* @return \Drupal\migrate\Plugin\MigrateIdMapInterface
* The map plugin that caused the event to fire.
*/
public function getMap() {
return $this->map;
}
/**
* Gets the source ID of the item being removed from the map.
*
* @return array
* Array of source ID fields.
*/
public function getSourceId() {
return $this->sourceId;
}
}

View file

@ -0,0 +1,60 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Wraps a migrate map save event for event listeners.
*/
class MigrateMapSaveEvent extends Event {
/**
* Map plugin.
*
* @var \Drupal\migrate\Plugin\MigrateIdMapInterface
*/
protected $map;
/**
* Array of fields being saved to the map, keyed by field name.
*
* @var array
*/
protected $fields;
/**
* Constructs a migration map event object.
*
* @param \Drupal\migrate\Plugin\MigrateIdMapInterface $map
* Map plugin.
* @param array $fields
* Array of fields being saved to the map.
*/
public function __construct(MigrateIdMapInterface $map, array $fields) {
$this->map = $map;
$this->fields = $fields;
}
/**
* Gets the map plugin.
*
* @return \Drupal\migrate\Plugin\MigrateIdMapInterface
* The map plugin that caused the event to fire.
*/
public function getMap() {
return $this->map;
}
/**
* Gets the fields about to be saved to the map.
*
* @return array
* Array of map fields, keyed by field name.
*/
public function getFields() {
return $this->fields;
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateMessageInterface;
use Drupal\migrate\Row;
/**
* Wraps a post-save event for event listeners.
*/
class MigratePostRowSaveEvent extends MigratePreRowSaveEvent {
/**
* The row's destination ID.
*
* @var array|bool
*/
protected $destinationIdValues = [];
/**
* Constructs a post-save event object.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param \Drupal\migrate\MigrateMessageInterface $message
* The message interface.
* @param \Drupal\migrate\Row $row
* Row object.
* @param array|bool $destination_id_values
* Values represent the destination ID.
*/
public function __construct(MigrationInterface $migration, MigrateMessageInterface $message, Row $row, $destination_id_values) {
parent::__construct($migration, $message, $row);
$this->destinationIdValues = $destination_id_values;
}
/**
* Gets the destination ID values.
*
* @return array
* The destination ID as an array.
*/
public function getDestinationIdValues() {
return $this->destinationIdValues;
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateMessageInterface;
use Drupal\migrate\Row;
/**
* Wraps a pre-save event for event listeners.
*/
class MigratePreRowSaveEvent extends EventBase {
/**
* Row object.
*
* @var \Drupal\migrate\Row
*/
protected $row;
/**
* Constructs a pre-save event object.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param \Drupal\migrate\MigrateMessageInterface $message
* The current migrate message service.
* @param \Drupal\migrate\Row $row
*/
public function __construct(MigrationInterface $migration, MigrateMessageInterface $message, Row $row) {
parent::__construct($migration, $message);
$this->row = $row;
}
/**
* Gets the row object.
*
* @return \Drupal\migrate\Row
* The row object about to be imported.
*/
public function getRow() {
return $this->row;
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Wraps a pre- or post-rollback event for event listeners.
*/
class MigrateRollbackEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Constructs an rollback event object.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
*/
public function __construct(MigrationInterface $migration) {
$this->migration = $migration;
}
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration entity involved.
*/
public function getMigration() {
return $this->migration;
}
}

View file

@ -0,0 +1,60 @@
<?php
namespace Drupal\migrate\Event;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Wraps a row deletion event for event listeners.
*/
class MigrateRowDeleteEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Values representing the destination ID.
*
* @var array
*/
protected $destinationIdValues;
/**
* Constructs a row deletion event object.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param array $destination_id_values
* Values represent the destination ID.
*/
public function __construct(MigrationInterface $migration, $destination_id_values) {
$this->migration = $migration;
$this->destinationIdValues = $destination_id_values;
}
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration being rolled back.
*/
public function getMigration() {
return $this->migration;
}
/**
* Gets the destination ID values.
*
* @return array
* The destination ID as an array.
*/
public function getDestinationIdValues() {
return $this->destinationIdValues;
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace Drupal\migrate\Event;
/**
* Interface for plugins that react to pre- or post-rollback events.
*/
interface RollbackAwareInterface {
/**
* Performs pre-rollback tasks.
*
* @param \Drupal\migrate\Event\MigrateRollbackEvent $event
* The pre-rollback event object.
*/
public function preRollback(MigrateRollbackEvent $event);
/**
* Performs post-rollback tasks.
*
* @param \Drupal\migrate\Event\MigrateRollbackEvent $event
* The post-rollback event object.
*/
public function postRollback(MigrateRollbackEvent $event);
}