You are here

public function SupportTicket::query in Support Ticketing System 8

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides SqlBase::query

File

modules/support_ticket/src/Plugin/migrate/source/d6/SupportTicket.php, line 122
Contains \Drupal\support_ticket\Plugin\migrate\source\d6\SupportTicket.

Class

SupportTicket
Drupal 6 support ticket source from database.

Namespace

Drupal\support_ticket\Plugin\migrate\source\d6

Code

public function query() {

  // Select support ticket / node in its last revision.
  $query = $this
    ->select('node_revisions', 'nr')
    ->fields('n', array(
    'nid',
    'vid',
    'type',
    'language',
    'status',
    'created',
    'changed',
    'comment',
    'moderate',
    'tnid',
    'translate',
  ))
    ->fields('st', array(
    'nid',
    'message_id',
    'state',
    'priority',
    'client',
    'assigned',
  ))
    ->fields('nr', array(
    'vid',
    'title',
    'body',
    'teaser',
    'log',
    'timestamp',
    'format',
  ));
  $query
    ->addField('n', 'uid', 'node_uid');
  $query
    ->addField('nr', 'uid', 'revision_uid');
  $query
    ->addField('ss', 'state', 'state_name');
  $query
    ->addField('sp', 'priority', 'priority_name');
  $query
    ->innerJoin('node', 'n', static::JOIN_NODE_REVISION);
  $query
    ->innerJoin('support_ticket', 'st', static::JOIN_TICKET);
  $query
    ->innerJoin('support_states', 'ss', static::JOIN_STATE);
  $query
    ->innerJoin('support_priority', 'sp', static::JOIN_PRIORITY);

  // @todo: get client name from appropriate table
  return $query;
}