Created
September 29, 2017 09:53
-
-
Save suryanto/bc6bb101fbfd78c7259041b088229195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\my_custom_migration\Plugin\migrate\source; | |
use Drupal\migrate\Plugin\migrate\source\SqlBase; | |
use Drupal\migrate\row; | |
/** | |
* Source plugin for company. | |
* | |
* @MigrateSource( | |
* id = "contact" | |
* ) | |
*/ | |
class Contact extends SqlBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function query() { | |
$query = $this->select('contact', 'ct') | |
->fields('ct', array( | |
'id', | |
'name', | |
'mobile_phone', | |
'company' | |
)); | |
return $query; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function fields() { | |
// TODO: Implement fields() method. | |
$fields = array( | |
'id' => $this->t('ID'), | |
'name' => $this->t('Contact Name'), | |
'mobile_phone' => $this->t('Mobile number'), | |
'company' => $this->t('Company') | |
); | |
return $fields; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function prepareRow(Row $row) { | |
//drush_print_r($row); | |
return parent::prepareRow($row); // TODO: Change the autogenerated stub | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getIds() { | |
// TODO: Implement getIds() method. | |
return [ | |
'id' => [ | |
'type' => 'integer', | |
'alias' => 'ct' | |
] | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment