Advertisement
Guest User

Untitled

a guest
Mar 28th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.93 KB | None | 0 0
  1. <?php
  2. // Определяем базовый класс с общими атрибутами и методами
  3. abstract class BasicGigMigration extends Migration {
  4.   public function __construct() {
  5.     parent::__construct();
  6.     $this->team = array(
  7.       new MigrateTeamMember('Руководитель', '***@mail.ru', t('Product Owner')),
  8.     );
  9.     $this->issuePattern = 'http://drupal.org/node/:id:';
  10.     Database::addConnectionInfo('for_migration', 'default', array(
  11.         'driver' => 'mysql',
  12.         'database' => '*******',
  13.         'username' => '*******',
  14.         'password' => '*******',
  15.         'host' => 'localhost',
  16.         'prefix' => '',
  17.     ));
  18.   }
  19. }
  20.  
  21. class BankiNodeMigration extends BasicGigMigration {
  22.   public function __construct() {
  23.     parent::__construct();
  24.     $this->description = t('Банки');
  25.  
  26.     // ***Схема***
  27.     // Связь источника и цели - описание ключевых полей таблиц.
  28.     $source_key_schema = MigrateDestinationNode::getKeySchema();
  29.     $this->map = new MigrateSQLMap($this->machineName, $source_key_schema, MigrateDestinationNode::getKeySchema());
  30.    
  31.     // ***Источник***
  32.     $query = Database::getConnection('default', 'for_migration')
  33.         ->select('node', 'ns')
  34.         ->fields('ns', array('nid', 'title', 'created', 'changed'))
  35.         ->condition('ns.type', "banki");
  36.     $this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => false));
  37.    
  38.     // ***Цель***
  39.     $this->destination = new MigrateDestinationNode('article');
  40.    
  41.     // ***Маппинг***
  42.     $this->addSimpleMappings(array('nid', 'title', 'created', 'changed'));
  43.    
  44.     // *** Не сопоставленные поля***
  45.     $this->addUnmigratedDestinations(array('vid', 'type', 'language', 'uid', 'status', 'comment', 'promote', 'sticky', 'tnid', 'translate'));
  46.     $this->addUnmigratedSources(array('vid', 'type', 'language', 'uid', 'status', 'comment', 'promote', 'sticky', 'tnid', 'translate'));
  47.  
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement