diff --git a/core/modules/migrate/src/Annotation/MigrateDestination.php b/core/modules/migrate/src/Annotation/MigrateDestination.php index 3837370..fdae657 100644 --- a/core/modules/migrate/src/Annotation/MigrateDestination.php +++ b/core/modules/migrate/src/Annotation/MigrateDestination.php @@ -12,10 +12,10 @@ /** * Defines a migration destination plugin annotation object. * - * Plugin Namespace: Plugin\migrate\destination + * Plugin Namespace: Plugin\migrate\destination. * * For a working example, see - * \Drupal\migrate\Plugin\migrate\destination\UrlAlias + * \Drupal\migrate\Plugin\migrate\destination\UrlAlias. * * @see \Drupal\migrate\Plugin\MigrateDestinationInterface * @see \Drupal\migrate\Plugin\destination\DestinationBase diff --git a/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php b/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php index d01eb7d..24cff31 100644 --- a/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php +++ b/core/modules/migrate/src/Annotation/MigrateProcessPlugin.php @@ -12,7 +12,7 @@ /** * Defines a migration process plugin annotation object. * - * Plugin Namespace: Plugin\migrate\process + * Plugin Namespace: Plugin\migrate\process. * * For a working example, see * \Drupal\migrate\Plugin\migrate\process\DefaultValue @@ -49,4 +49,5 @@ class MigrateProcessPlugin extends Plugin { * @var bool (optional) */ public $handle_multiples = FALSE; + } diff --git a/core/modules/migrate/src/Annotation/MigrateSource.php b/core/modules/migrate/src/Annotation/MigrateSource.php index 95b53e3..ca35355 100644 --- a/core/modules/migrate/src/Annotation/MigrateSource.php +++ b/core/modules/migrate/src/Annotation/MigrateSource.php @@ -12,7 +12,7 @@ /** * Defines a migration source plugin annotation object. * - * Plugin Namespace: Plugin\migrate\source + * Plugin Namespace: Plugin\migrate\source. * * For a working example, check * \Drupal\migrate\Plugin\migrate\source\EmptySource diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index 9e509f4..24f0fbe 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -150,7 +150,9 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem protected $highWaterProperty; /** - * Indicate whether the primary system of record for this migration is the + * Specifies the primary system of record for this migration. + * + * Indicates whether the primary system of record for this migration is the * source, or the destination (Drupal). In the source case, migration of * an existing object will completely replace the Drupal object with data from * the source side. In the destination case, the existing Drupal object will @@ -162,14 +164,17 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem protected $systemOfRecord = self::SOURCE; /** - * Specify value of source_row_status for current map row. Usually set by - * MigrateFieldHandler implementations. + * Specifies the value of source_row_status for current map row. + * + * Usually this is set by MigrateFieldHandler implementations. * * @var int */ protected $sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED; /** + * The highwater value for this migration. + * * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface */ protected $highWaterStorage; @@ -291,7 +296,7 @@ public function getProcessPlugins(array $process = NULL) { } /** - * Resolve shorthands into a list of plugin configurations. + * Resolves shorthands into a list of plugin configurations. * * @param array $process * A process configuration array. @@ -342,7 +347,7 @@ public function getIdMap() { } /** - * Get the high water storage object. + * Gets the high water storage object. * * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface * The storage object. @@ -397,7 +402,7 @@ public function checkRequirements() { } /** - * Get the entity manager. + * Gets the entity manager. * * @return \Drupal\Core\Entity\EntityManagerInterface * The entity manager. @@ -519,7 +524,7 @@ public function setProcessOfProperty($property, $process_of_property) { */ public function mergeProcessOfProperty($property, array $process_of_property) { // If we already have a process value then merge the incoming process array - //otherwise simply set it. + // otherwise simply set it. $current_process = $this->getProcess(); if (isset($current_process[$property])) { $this->process = NestedArray::mergeDeepArray([$current_process, $this->getProcessNormalized([$property => $process_of_property])], TRUE); @@ -595,4 +600,5 @@ public function calculateDependencies() { return $this; } + } diff --git a/core/modules/migrate/src/Entity/MigrationInterface.php b/core/modules/migrate/src/Entity/MigrationInterface.php index a07c0ea..938a6ef 100644 --- a/core/modules/migrate/src/Entity/MigrationInterface.php +++ b/core/modules/migrate/src/Entity/MigrationInterface.php @@ -110,8 +110,8 @@ public function getSourcePlugin(); /** * Returns the process plugins. * - * @param array $process - * A process configuration array. + * @param array|null $process + * (optional) A process configuration array. Defaults to NULL. * * @return \Drupal\migrate\Plugin\MigrateProcessInterface[][] * An associative array. The keys are the destination property names. Values @@ -123,7 +123,8 @@ public function getProcessPlugins(array $process = NULL); * Returns the initialized destination plugin. * * @param bool $stub_being_requested - * TRUE to indicate that this destination will be asked to construct a stub. + * (optional) TRUE to indicate that this destination will be asked to + * construct a stub. Defaults to FALSE. * * @return \Drupal\migrate\Plugin\MigrateDestinationInterface * The destination plugin. @@ -139,10 +140,10 @@ public function getDestinationPlugin($stub_being_requested = FALSE); public function getIdMap(); /** - * The current value of the high water mark. + * Returns the current value of the high water mark. * - * The high water mark defines a timestamp stating the time the import was last - * run. If the mark is set, only content with a higher timestamp will be + * The high water mark defines a timestamp stating the time the import was + * last run. If the mark is set, only content with a higher timestamp will be * imported. * * @return int @@ -151,7 +152,7 @@ public function getIdMap(); public function getHighWater(); /** - * Save the new high water mark. + * Saves the new high water mark. * * @param int $high_water * The high water timestamp. @@ -159,7 +160,7 @@ public function getHighWater(); public function saveHighWater($high_water); /** - * Check if all source rows from this migration have been processed. + * Checks if all source rows from this migration have been processed. * * @return bool * TRUE if this migration is complete otherwise FALSE. @@ -167,15 +168,15 @@ public function saveHighWater($high_water); public function allRowsProcessed(); /** - * Set the current migration status. + * Sets the current migration status. * - * @param int $result + * @param int $status * One of the STATUS_* constants. */ public function setStatus($status); /** - * Get the current migration status. + * Gets the current migration status. * * @return int * The current migration status. Defaults to STATUS_IDLE. @@ -183,7 +184,7 @@ public function setStatus($status); public function getStatus(); /** - * Retrieve a label for the current status. + * Retrieves a label for the current status. * * @return string * User-friendly string corresponding to a STATUS_ constant. @@ -191,7 +192,7 @@ public function getStatus(); public function getStatusLabel(); /** - * Get the result to return upon interruption. + * Gets the result to return upon interruption. * * @return int * The current interruption result. Defaults to RESULT_INCOMPLETE. @@ -204,8 +205,9 @@ public function getInterruptionResult(); public function clearInterruptionResult(); /** - * Signal that the migration should be interrupted with the specified result - * code. + * Signals that the migration should be interrupted. + * + * The migration will be interrupted with the specified result code. * * @param int $result * One of the MigrationInterface::RESULT_* constants. @@ -213,8 +215,7 @@ public function clearInterruptionResult(); public function interruptMigration($result); /** - * Get the normalized process pipeline configuration describing the process - * plugins. + * Gets process pipeline configuration describing the process plugins. * * The process configuration is always normalized. All shorthand processing * will be expanded into their full representations. @@ -237,7 +238,7 @@ public function getProcess(); public function setProcess(array $process); /** - * Set the process pipeline configuration for an individual destination field. + * Sets process pipeline configuration for an individual destination field. * * This method allows you to set the process pipeline configuration for a * single property within the full process pipeline configuration. @@ -253,24 +254,23 @@ public function setProcess(array $process); public function setProcessOfProperty($property, $process_of_property); /** - * Merge the process pipeline configuration for a single property. + * Merges the process pipeline configuration for a single property. * * @param string $property * The property of which to merge the passed in process pipeline - * configuration. + * configuration. * @param array $process_of_property * The process pipeline configuration to be merged with the existing process - * pipeline configuration. + * pipeline configuration. * * @return $this - * The migration entity. * - * @see Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity::processLinkField(). + * @see Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity::processLinkField() */ public function mergeProcessOfProperty($property, array $process_of_property); /** - * Get the current system of record of the migration. + * Gets the current system of record of the migration. * * @return string * The current system of record of the migration. @@ -278,7 +278,7 @@ public function mergeProcessOfProperty($property, array $process_of_property); public function getSystemOfRecord(); /** - * Set the system of record for the migration. + * Sets the system of record for the migration. * * @param string $system_of_record * The system of record of the migration. @@ -296,7 +296,7 @@ public function setSystemOfRecord($system_of_record); public function isTrackLastImported(); /** - * Set if the migration should track time of last import. + * Sets if the migration should track time of last import. * * @param bool $track_last_imported * Boolean value to indicate if the migration should track last import time. @@ -306,7 +306,7 @@ public function isTrackLastImported(); public function setTrackLastImported($track_last_imported); /** - * Get the dependencies for this migration. + * Gets the dependencies for this migration. * * @return array * The dependencies for this migrations. diff --git a/core/modules/migrate/src/Event/MigrateEvents.php b/core/modules/migrate/src/Event/MigrateEvents.php index d350245..134dc35 100644 --- a/core/modules/migrate/src/Event/MigrateEvents.php +++ b/core/modules/migrate/src/Event/MigrateEvents.php @@ -41,7 +41,8 @@ * * 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. + * listener method receives a \Drupal\migrate\Event\MigrateMapDeleteEvent + * instance. * * @Event * diff --git a/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php b/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php index e6fe02e..0f54e91 100644 --- a/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php +++ b/core/modules/migrate/src/Event/MigrateIdMapMessageEvent.php @@ -51,7 +51,7 @@ class MigrateIdMapMessageEvent extends Event { * @param array $source_id_values * Values represent the source ID. * @param string $message - * The message + * The message to be logged. * @param int $level * Severity level (one of the MigrationInterface::MESSAGE_* constants). */ @@ -93,8 +93,9 @@ public function getMessage() { } /** - * Gets the severity level of the message (one of the - * MigrationInterface::MESSAGE_* constants). + * Gets the severity level of the message. + * + * This will be one of the MigrationInterface::MESSAGE_* constants. * * @return int * The message level. diff --git a/core/modules/migrate/src/Event/MigrateMapDeleteEvent.php b/core/modules/migrate/src/Event/MigrateMapDeleteEvent.php index 2ca3b25..ac96ed8 100644 --- a/core/modules/migrate/src/Event/MigrateMapDeleteEvent.php +++ b/core/modules/migrate/src/Event/MigrateMapDeleteEvent.php @@ -35,7 +35,8 @@ class MigrateMapDeleteEvent extends Event { * @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. + * Array of source ID fields representing the object being deleted from the + * map. */ public function __construct(MigrateIdMapInterface $map, array $source_id) { $this->map = $map; diff --git a/core/modules/migrate/src/Exception/RequirementsException.php b/core/modules/migrate/src/Exception/RequirementsException.php index 5843de2..327fcb6 100644 --- a/core/modules/migrate/src/Exception/RequirementsException.php +++ b/core/modules/migrate/src/Exception/RequirementsException.php @@ -10,7 +10,7 @@ use Exception; /** - * Defines an + * Defines a requirements exception. * * @see \Drupal\migrate\Plugin\RequirementsInterface */ @@ -27,13 +27,14 @@ class RequirementsException extends \RuntimeException { * Constructs a new RequirementsException instance. * * @param string $message - * (optional) The Exception message to throw. + * (optional) The Exception message to throw. Defaults to an empty string. * @param array $requirements - * (optional) The missing requirements. + * (optional) The missing requirements. Defaults to an empty array. * @param int $code - * (optional) The Exception code. + * (optional) The Exception code. Defaults to zero. * @param \Exception $previous * (optional) The previous exception used for the exception chaining. + * Defaults to NULL. */ public function __construct($message = "", array $requirements = [], $code = 0, Exception $previous = NULL) { parent::__construct($message, $code, $previous); @@ -42,7 +43,7 @@ public function __construct($message = "", array $requirements = [], $code = 0, } /** - * Get an array of requirements. + * Gets an array of requirements. * * @return array * The requirements. @@ -52,7 +53,7 @@ public function getRequirements() { } /** - * Get the requirements as a string. + * Gets the requirements as a string. * * @return string * A formatted requirements string. diff --git a/core/modules/migrate/src/MigrateBuildDependencyInterface.php b/core/modules/migrate/src/MigrateBuildDependencyInterface.php index dbf8694..66c86f7 100644 --- a/core/modules/migrate/src/MigrateBuildDependencyInterface.php +++ b/core/modules/migrate/src/MigrateBuildDependencyInterface.php @@ -1,4 +1,5 @@ level = $level; @@ -58,7 +61,9 @@ public function __construct($message = NULL, $code = 0, \Exception $previous = N * Gets the level. * * @return int - * An integer status code. @see Migration::MESSAGE_* + * An integer status code. + * + * @see Migration::MESSAGE_* */ public function getLevel() { return $this->level; @@ -68,7 +73,9 @@ public function getLevel() { * Gets the status of the current item. * * @return int - * An integer status code. @see MigrateMap::STATUS_* + * An integer status code. + * + * @see MigrateMap::STATUS_* */ public function getStatus() { return $this->status; diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index a370623..cd3ce24 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -106,8 +106,8 @@ class MigrateExecutable implements MigrateExecutableInterface { * The migration to run. * @param \Drupal\migrate\MigrateMessageInterface $message * The message to record. - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher - * The event dispatcher. + * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface|null $event_dispatcher + * The event dispatcher. Defaults to NULL. * * @throws \Drupal\migrate\MigrateException */ @@ -116,7 +116,7 @@ public function __construct(MigrationInterface $migration, MigrateMessageInterfa $this->message = $message; $this->migration->getIdMap()->setMessage($message); $this->eventDispatcher = $event_dispatcher; - // Record the memory limit in bytes + // Record the memory limit in bytes. $limit = trim(ini_get('memory_limit')); if ($limit == '-1') { $this->memoryLimit = PHP_INT_MAX; @@ -132,6 +132,7 @@ public function __construct(MigrationInterface $migration, MigrateMessageInterfa case 'k': $limit *= 1024; break; + default: $limit = PHP_INT_MAX; $this->message->display($this->t('Invalid PHP memory_limit @limit, setting to unlimited.', @@ -161,6 +162,7 @@ protected function getSource() { * Gets the event dispatcher. * * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface + * The event dispatcher service. */ protected function getEventDispatcher() { if (!$this->eventDispatcher) { @@ -311,8 +313,8 @@ public function rollback() { // Announce that rollback is about to happen. $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROLLBACK, new MigrateRollbackEvent($this->migration)); - // Optimistically assume things are going to work out; if not, $return will be - // updated to some other status. + // Optimistically assume things are going to work out; if not, $return will + // be updated to some other status. $return = MigrationInterface::RESULT_COMPLETED; $this->migration->setStatus(MigrationInterface::STATUS_ROLLING_BACK); @@ -436,7 +438,8 @@ public function saveMessage($message, $level = MigrationInterface::MESSAGE_ERROR * Object representing the exception. * @param bool $save * (optional) Whether to save the message in the migration's mapping table. - * Set to FALSE in contexts where this doesn't make sense. + * Set to FALSE in contexts where this does not make sense. Defaults to + * TRUE. */ protected function handleException(\Exception $exception, $save = TRUE) { $result = Error::decodeException($exception); @@ -458,7 +461,7 @@ protected function checkStatus() { } /** - * Tests whether we've exceeded the desired memory threshold. + * Tests whether we have exceeded the desired memory threshold. * * If so, output a message. * @@ -474,18 +477,18 @@ protected function memoryExceeded() { if ($pct_memory > $threshold) { $this->message->display( $this->t('Memory usage is @usage (@pct% of limit @limit), reclaiming memory.', - array('@pct' => round($pct_memory*100), + array('@pct' => round($pct_memory * 100), '@usage' => $this->formatSize($usage), '@limit' => $this->formatSize($this->memoryLimit))), 'warning'); $usage = $this->attemptMemoryReclaim(); $pct_memory = $usage / $this->memoryLimit; - // Use a lower threshold - we don't want to be in a situation where we keep - // coming back here and trimming a tiny amount + // Use a lower threshold - we do not want to be in a situation where we + // keep coming back here and trimming a tiny amount. if ($pct_memory > (0.90 * $threshold)) { $this->message->display( $this->t('Memory usage is now @usage (@pct% of limit @limit), not enough reclaimed, starting new batch', - array('@pct' => round($pct_memory*100), + array('@pct' => round($pct_memory * 100), '@usage' => $this->formatSize($usage), '@limit' => $this->formatSize($this->memoryLimit))), 'warning'); @@ -494,7 +497,7 @@ protected function memoryExceeded() { else { $this->message->display( $this->t('Memory usage is now @usage (@pct% of limit @limit), reclaimed enough, continuing', - array('@pct' => round($pct_memory*100), + array('@pct' => round($pct_memory * 100), '@usage' => $this->formatSize($usage), '@limit' => $this->formatSize($this->memoryLimit))), 'warning'); @@ -528,12 +531,13 @@ protected function attemptMemoryReclaim() { drupal_static_reset(); // Entity storage can blow up with caches so clear them out. - $manager = \Drupal::entityManager(); + $manager = \Drupal::entityManager(); foreach ($manager->getDefinitions() as $id => $definition) { $manager->getStorage($id)->resetCache(); } - // @TODO: explore resetting the container. + // @todo Explore resetting the container. This should be addressed in issue + // https://www.drupal.org/node/2545632. return memory_get_usage(); } diff --git a/core/modules/migrate/src/MigrateExecutableInterface.php b/core/modules/migrate/src/MigrateExecutableInterface.php index 71fa017..771aca6 100644 --- a/core/modules/migrate/src/MigrateExecutableInterface.php +++ b/core/modules/migrate/src/MigrateExecutableInterface.php @@ -9,6 +9,9 @@ use Drupal\migrate\Entity\MigrationInterface; +/** + * Defines an interface for a migration executable class. + */ interface MigrateExecutableInterface { /** @@ -28,14 +31,14 @@ public function rollback(); * The $row to be processed. * @param array $process * (optional) A process pipeline configuration. If not set, the top level - * process configuration in the migration entity is used. + * process configuration in the migration entity is used. Defaults to NULL. * @param mixed $value * (optional) Initial value of the pipeline for the first destination. * Usually setting this is not necessary as $process typically starts with * a 'get'. This is useful only when the $process contains a single * destination and needs to access a value outside of the source. See * \Drupal\migrate\Plugin\migrate\process\Iterator::transformKey for an - * example. + * example. Defaults to NULL. * * @throws \Drupal\migrate\MigrateException */ @@ -47,7 +50,8 @@ public function processRow(Row $row, array $process = NULL, $value = NULL); * @param string $message * The message to record. * @param int $level - * (optional) Message severity (defaults to MESSAGE_ERROR). + * (optional) Message severity. Defaults to + * MigrationInterface::MESSAGE_ERROR. */ public function saveMessage($message, $level = MigrationInterface::MESSAGE_ERROR); diff --git a/core/modules/migrate/src/MigrateMessageInterface.php b/core/modules/migrate/src/MigrateMessageInterface.php index 2a35c8d..4069547 100644 --- a/core/modules/migrate/src/MigrateMessageInterface.php +++ b/core/modules/migrate/src/MigrateMessageInterface.php @@ -1,4 +1,5 @@ getSource(), $this->sourceIds, $this->isStub()))->freezeSource(); @@ -246,7 +247,7 @@ public function getDestination() { /** * Returns the raw destination. Rarely necessary. * - * For example calling setDestination('foo/bar', 'baz') results in + * For example, calling setDestination('foo/bar', 'baz') results in: * @code * $this->destination['foo']['bar'] = 'baz'; * $this->rawDestination['foo/bar'] = 'baz'; @@ -322,7 +323,7 @@ public function needsUpdate() { } /** - * Returns the hash for the source values.. + * Returns the hash for the source values. * * @return mixed * The hash of the source values. @@ -340,4 +341,5 @@ public function getHash() { public function isStub() { return $this->isStub; } + }