Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $timezone = NULL;
     if ($row->hasSourceProperty('timezone_name')) {
         if (isset(static::$timezones[$row->getSourceProperty('timezone_name')])) {
             $timezone = $row->getSourceProperty('timezone_name');
         }
     }
     if (!$timezone && $row->hasSourceProperty('event_timezone')) {
         if (isset(static::$timezones[$row->getSourceProperty('event_timezone')])) {
             $timezone = $row->getSourceProperty('event_timezone');
         }
     }
     return $timezone;
 }
Ejemplo n.º 2
0
  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    // User roles.
    $roles = $this->select('users_roles', 'ur')
      ->fields('ur', array('rid'))
      ->condition('ur.uid', $row->getSourceProperty('uid'))
      ->execute()
      ->fetchCol();
    $row->setSourceProperty('roles', $roles);

    // We are adding here the Event contributed module column.
    // @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
    if ($row->hasSourceProperty('timezone_id') && $row->getSourceProperty('timezone_id')) {
      if ($this->getDatabase()->schema()->tableExists('event_timezones')) {
        $event_timezone = $this->select('event_timezones', 'e')
          ->fields('e', array('name'))
          ->condition('e.timezone', $row->getSourceProperty('timezone_id'))
          ->execute()
          ->fetchField();
        if ($event_timezone) {
          $row->setSourceProperty('event_timezone', $event_timezone);
        }
      }
    }

    // Unserialize Data.
    $row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));

    return parent::prepareRow($row);
  }