Agreement.php in Agreement 3.0.x
File
src/Plugin/migrate/source/Agreement.php
View source
<?php
namespace Drupal\agreement\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class Agreement extends DrupalSqlBase {
public function getIds() {
return [
'id' => [
'type' => 'integer',
],
];
}
public function fields() {
$fields = [
'id' => $this
->t('Unique Identifier'),
'uid' => $this
->t('User Identifier'),
'sid' => $this
->t('Session Identifier'),
'agreed' => $this
->t('Agreed?'),
'agreed_date' => $this
->t('Agreement timestamp'),
];
if ($this
->needsAgreementType()) {
$fields['type'] = $this
->t('Agreement type');
}
return $fields;
}
public function query() {
$fields = $this
->fields();
return $this
->select('agreement', 'agreement')
->fields('agreement', array_keys($fields));
}
protected function needsAgreementType() {
$version = isset($this->configuration['version']) ? (int) $this->configuration['version'] : 7;
return $version === 7;
}
}