Commit 5636af45 authored by alexpott's avatar alexpott

Issue #2624888 by Lars Toomre: More fixes to migrate/src/Plugin/*.php files

parent cf0d367b
......@@ -12,7 +12,7 @@
use Drupal\migrate\Plugin\MigrateBuilderInterface;
/**
* Base class for builder plugins.
* Provides abstract base class for builder plugins.
*/
abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface {
......@@ -22,7 +22,8 @@ abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface
* @param string $plugin_id
* The plugin ID.
* @param array $configuration
* (optional) Additional configuration for the plugin.
* (optional) Additional configuration for the plugin. Defaults to an empty
* array.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface
* The fully initialized source plugin.
......
......@@ -10,6 +10,9 @@
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
/**
* Defines the base abstract class for component entity display.
*/
abstract class ComponentEntityDisplayBase extends DestinationBase {
const MODE_NAME = '';
......@@ -54,7 +57,7 @@ public function fields(MigrationInterface $migration = NULL) {
}
/**
* Get the entity.
* Gets the entity.
*
* @param string $entity_type
* The entity type to retrieve.
......
......@@ -3,8 +3,6 @@
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\Config.
*
* Provides Configuration Management destination plugin.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
......@@ -18,6 +16,8 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides Configuration Management destination plugin.
*
* Persist data to the config system.
*
* When a property is NULL, the default is used unless the configuration option
......@@ -28,6 +28,7 @@
* )
*/
class Config extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface {
use DependencyTrait;
/**
......
......@@ -5,7 +5,6 @@
* Contains \Drupal\migrate\Plugin\migrate\destination\DestinationBase.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Plugin\PluginBase;
......@@ -113,4 +112,5 @@ protected function setRollbackAction(array $id_map) {
$this->rollbackAction = MigrateIdMapInterface::ROLLBACK_PRESERVE;
}
}
}
......@@ -16,12 +16,15 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides entity destination plugin.
*
* @MigrateDestination(
* id = "entity",
* deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntity"
* )
*/
abstract class Entity extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface {
use DependencyTrait;
/**
......@@ -86,7 +89,7 @@ public static function create(ContainerInterface $container, array $configuratio
* The entity type.
*/
protected static function getEntityTypeId($plugin_id) {
// Remove "entity:"
// Remove "entity:".
return substr($plugin_id, 7);
}
......@@ -125,13 +128,13 @@ protected function getEntity(Row $row, array $old_destination_id_values) {
}
/**
* Get the entity ID of the row.
* Gets the entity ID of the row.
*
* @param \Drupal\migrate\Row $row
* The row of data.
*
* @return string
* The entity ID for the row we are importing.
* The entity ID for the row that we are importing.
*/
protected function getEntityId(Row $row) {
return $row->getDestinationProperty($this->getKey('id'));
......
......@@ -10,6 +10,8 @@
use Drupal\migrate\Row;
/**
* Provides entity base field override plugin.
*
* @MigrateDestination(
* id = "entity:base_field_override"
* )
......
......@@ -105,7 +105,7 @@ protected function updateEntityProperty(EntityInterface $entity, array $parents,
}
/**
* Generate an entity ID.
* Generates an entity ID.
*
* @param \Drupal\migrate\Row $row
* The current row.
......
......@@ -7,15 +7,12 @@
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Utility\Random;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\link\LinkItemInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
......@@ -97,7 +94,7 @@ public function import(Row $row, array $old_destination_id_values = array()) {
}
/**
* Save the entity.
* Saves the entity.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The content entity.
......@@ -122,7 +119,7 @@ public function getIds() {
}
/**
* Update an entity with the new values from row.
* Updates an entity with the new values from row.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to update.
......@@ -152,7 +149,7 @@ protected function updateEntity(EntityInterface $entity, Row $row) {
}
/**
* Do as much population of the stub row as we can.
* Populates as much of the stub row as possible.
*
* @param \Drupal\migrate\Row $row
* The row of data.
......@@ -185,7 +182,6 @@ protected function processStubRow(Row $row) {
if (is_null($values)) {
// Handle failure to generate a sample value.
throw new MigrateException('Stubbing failed, unable to generate value for field ' . $field_name);
break;
}
}
......
......@@ -8,6 +8,8 @@
namespace Drupal\migrate\Plugin\migrate\destination;
/**
* Provides entity field instance plugin.
*
* @MigrateDestination(
* id = "entity:field_config"
* )
......
......@@ -8,6 +8,8 @@
namespace Drupal\migrate\Plugin\migrate\destination;
/**
* Provides entity field storage configuration plugin.
*
* @MigrateDestination(
* id = "entity:field_storage_config"
* )
......
......@@ -12,6 +12,8 @@
use Drupal\migrate\Row;
/**
* Provides entity revision destination plugin.
*
* @MigrateDestination(
* id = "entity_revision",
* deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntityRevision"
......@@ -28,12 +30,12 @@ protected static function getEntityTypeId($plugin_id) {
}
/**
* Get the entity.
* Gets the entity.
*
* @param \Drupal\migrate\Row $row
* The row object.
* @param array $old_destination_id_values
* The old destination ids.
* The old destination IDs.
*
* @return \Drupal\Core\Entity\EntityInterface|false
* The entity or false if it can not be created.
......
......@@ -8,6 +8,8 @@
namespace Drupal\migrate\Plugin\migrate\destination;
/**
* Provides entity view mode destination plugin.
*
* @MigrateDestination(
* id = "entity:entity_view_mode"
* )
......
......@@ -11,6 +11,8 @@
use Drupal\migrate\Row;
/**
* Provides null destination plugin.
*
* @MigrateDestination(
* id = "null",
* requirements_met = false
......
......@@ -69,6 +69,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
protected $database;
/**
* The select query.
*
* @var \Drupal\Core\Database\Query\SelectInterface
*/
protected $query;
......@@ -383,23 +385,26 @@ protected function ensureTables() {
// Add any missing columns to the map table.
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName,
'rollback_action')) {
$this->getDatabase()->schema()->addField($this->mapTableName,
'rollback_action', array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
));
$this->getDatabase()->schema()->addField($this->mapTableName, 'rollback_action',
array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
)
);
}
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName, 'hash')) {
$this->getDatabase()->schema()->addField($this->mapTableName, 'hash', array(
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
));
$this->getDatabase()->schema()->addField($this->mapTableName, 'hash',
array(
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
)
);
}
}
}
......@@ -410,9 +415,10 @@ protected function ensureTables() {
* @param array $id_definition
* A field schema definition. Can be SQL schema or a type data
* based schema. In the latter case, the value of type needs to be
* $typed_data_type.$column
* $typed_data_type.$column.
*
* @return array
* The schema definition.
*/
protected function getFieldSchema(array $id_definition) {
$type_parts = explode('.', $id_definition['type']);
......@@ -594,8 +600,8 @@ public function getMessageIterator(array $source_id_values = [], $level = NULL)
*/
public function prepareUpdate() {
$this->getDatabase()->update($this->mapTableName())
->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
->execute();
->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
->execute();
}
/**
......@@ -643,10 +649,11 @@ public function messageCount() {
/**
* Counts records in a table.
*
* @param $status
* @param int $status
* An integer for the source_row_status column.
* @param $table
* The table to work
* @param string $table
* (optional) The table to work. Defaults to NULL.
*
* @return int
* The number of records.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment