l10n_server-2.x-dev/l10n_migrate/src/Plugin/migrate/source/L10nServerProject.php
l10n_migrate/src/Plugin/migrate/source/L10nServerProject.php
<?php declare(strict_types=1); namespace Drupal\l10n_migrate\Plugin\migrate\source; use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Site\Settings; use Drupal\migrate\Plugin\migrate\source\SqlBase; /** * Migrate Source plugin. * * @MigrateSource( * id = "l10n_migrate_server_project", * source_module = "l10n_migrate", * ) */ class L10nServerProject extends SqlBase { /** * {@inheritdoc} */ public function query(): SelectInterface { $query = $this ->select('l10n_server_project', 'p') ->fields( 'p', [ 'pid', 'title', 'uri', 'connector_module', 'home_link', 'last_parsed', 'status', 'weight', ] ); if ($pid = Settings::get('l10n_migrate_project_only')) { $query->condition('pid', $pid); } return $query; } /** * {@inheritdoc} */ public function fields(): array { return [ 'pid' => $this->t('Project ID'), 'title' => $this->t('Title'), 'uri' => $this->t('URI'), 'connector_module' => $this->t('Connector module'), // @todo home_link (text) to homepage (varchar(255)). 'home_link' => $this->t('Homepage'), 'last_parsed' => $this->t('Last parsed'), // @todo status (int(11)) to status (int(4)). 'status' => $this->t('Status'), 'weight' => $this->t('Weight'), ]; } /** * {@inheritdoc} */ public function getIds(): array { return [ 'pid' => [ 'type' => 'integer', 'alias' => 'p', ], ]; } }