l10n_server-2.x-dev/l10n_migrate/src/Plugin/migrate/source/L10nServerString.php

l10n_migrate/src/Plugin/migrate/source/L10nServerString.php
<?php
declare(strict_types=1);

namespace Drupal\l10n_migrate\Plugin\migrate\source;

use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;

/**
 * Migrate Source plugin.
 *
 * @MigrateSource(
 *   id = "l10n_migrate_server_string",
 *   source_module = "l10n_migrate",
 * )
 */
class L10nServerString extends SqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this
      ->select('l10n_server_string', 's')
      ->fields('s', ['sid', 'value', 'context', 'hashkey']);
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    return [
      'sid' => $this->t('String ID'),
      'value' => $this->t('Value'),
      'context' => $this->t('Context'),
      'hashkey' => $this->t('Hashkey'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    return [
      'sid' => [
        'type' => 'integer',
        'alias' => 's',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    if (!$row->getSourceProperty('value')) {
      return FALSE;
    }
    return parent::prepareRow($row);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc