CustomPub.php in Custom Publishing Options 8
File
src/Plugin/migrate/source/d7/CustomPub.php
View source
<?php
namespace Drupal\custom_pub\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class CustomPub extends DrupalSqlBase {
public function query() {
$query = $this
->select('node', 'n')
->fields('n');
if (isset($this->configuration['node_type'])) {
$query
->condition('n.type', $this->configuration['node_type']);
}
return $query;
}
public function fields() {
$fields = [
'nid' => $this
->t('Node ID'),
];
$publishing_options = unserialize($this
->getDatabase()
->select('variable', 'v')
->fields('v', [
'value',
])
->condition('name', 'custom_pub_types')
->execute()
->fetchField());
foreach ($publishing_options as $key => $publishing_option) {
$fields[$key] = $publishing_option['name'];
}
return $fields;
}
public function getIds() {
$ids['nid']['type'] = 'integer';
return $ids;
}
}