Table.php in Migrate Plus 8.5
File
src/Plugin/migrate/source/Table.php
View source
<?php
namespace Drupal\migrate_plus\Plugin\migrate\source;
use Drupal\Core\State\StateInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Plugin\MigrationInterface;
class Table extends SqlBase {
const TABLE_ALIAS = 't';
protected $tableName;
protected $idFields;
protected $fields;
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state);
$this->tableName = $configuration['table_name'];
foreach ($configuration['id_fields'] as &$field) {
$field['alias'] = static::TABLE_ALIAS;
}
$this->idFields = $configuration['id_fields'];
$this->fields = isset($configuration['fields']) ? $configuration['fields'] : [];
}
public function query() {
return $this
->select($this->tableName, static::TABLE_ALIAS)
->fields(static::TABLE_ALIAS, $this->fields);
}
public function fields() {
return $this->fields;
}
public function getIds() {
if (empty($this->idFields)) {
throw new MigrateException('Id fields are required for a table source');
}
return $this->idFields;
}
}
Classes
Name |
Description |
Table |
Source plugin for retrieving data via URLs. |