class Upload

Same name and namespace in other branches
  1. 10 core/modules/file/src/Plugin/migrate/source/d6/Upload.php \Drupal\file\Plugin\migrate\source\d6\Upload
  2. 11.x core/modules/file/src/Plugin/migrate/source/d6/Upload.php \Drupal\file\Plugin\migrate\source\d6\Upload
  3. 8.9.x core/modules/file/src/Plugin/migrate/source/d6/Upload.php \Drupal\file\Plugin\migrate\source\d6\Upload

Drupal 6 upload source from database.

For available configuration keys, refer to the parent classes.

Plugin annotation


@MigrateSource(
  id = "d6_upload",
  source_module = "upload"
)

Hierarchy

Expanded class hierarchy of Upload

See also

\Drupal\migrate\Plugin\migrate\source\SqlBase

\Drupal\migrate\Plugin\migrate\source\SourcePluginBase

50 string references to 'Upload'
ConfigExportImportUITest::testExportImport in core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
Tests a simple site export import case.
ConfigExportImportUITest::testExportImportCollections in core/modules/config/tests/src/Functional/ConfigExportImportUITest.php
Tests an export and import of collections.
ConfigImportForm::buildForm in core/modules/config/src/Form/ConfigImportForm.php
ConfigImportUploadTest::testImport in core/modules/config/tests/src/Functional/ConfigImportUploadTest.php
Tests importing configuration.
ContentEntityFormFieldValidationFilteringTest::testFieldWidgetsWithLimitedValidationErrors in core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormFieldValidationFilteringTest.php
Tests field widgets with #limit_validation_errors.

... See full list

File

core/modules/file/src/Plugin/migrate/source/d6/Upload.php, line 21

Namespace

Drupal\file\Plugin\migrate\source\d6
View source
class Upload extends DrupalSqlBase {
  
  /**
   * The join options between the node and the upload table.
   */
  const JOIN = '[n].[nid] = [u].[nid] AND [n].[vid] = [u].[vid]';
  
  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('upload', 'u')
      ->distinct()
      ->fields('u', [
      'nid',
      'vid',
    ]);
    $query->innerJoin('node', 'n', static::JOIN);
    $query->addField('n', 'type');
    $query->addField('n', 'language');
    return $query;
  }
  
  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    $query = $this->select('upload', 'u')
      ->fields('u', [
      'fid',
      'description',
      'list',
    ])
      ->condition('u.nid', $row->getSourceProperty('nid'))
      ->orderBy('u.weight');
    $query->innerJoin('node', 'n', static::JOIN);
    $row->setSourceProperty('upload', $query->execute()
      ->fetchAll());
    return parent::prepareRow($row);
  }
  
  /**
   * {@inheritdoc}
   */
  public function fields() {
    return [
      'fid' => $this->t('The file Id.'),
      'nid' => $this->t('The node Id.'),
      'vid' => $this->t('The version Id.'),
      'type' => $this->t('The node type'),
      'language' => $this->t('The node language.'),
      'description' => $this->t('The file description.'),
      'list' => $this->t('Whether the list should be visible on the node page.'),
      'weight' => $this->t('The file weight.'),
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['vid']['type'] = 'integer';
    $ids['vid']['alias'] = 'u';
    return $ids;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.