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\Core\Database\Query\SelectInterface;
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(): SelectInterface {
    return $this
      ->select('l10n_server_string', 's')
      ->fields(
        's',
        [
          'sid',
          'value',
          'context',
          'hashkey',
        ]
      );
  }

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

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

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

    return parent::prepareRow($row);
  }

}

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

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