3 namespace Drupal\file\Plugin\migrate\source\d6;
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Plugin\migrate\source\DummyQueryTrait;
9 * Drupal 6 upload instance source from database.
12 * id = "d6_upload_instance",
13 * source_module = "upload"
16 class UploadInstance extends DrupalSqlBase {
23 protected function initializeIterator() {
24 $node_types = $this->select('node_type', 'nt')
25 ->fields('nt', ['type'])
28 $variables = array_map(function ($type) {
29 return 'upload_' . $type;
32 $max_filesize = $this->variableGet('upload_uploadsize_default', 1);
33 $max_filesize = $max_filesize ? $max_filesize . 'MB' : '';
34 $file_extensions = $this->variableGet('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
36 $values = $this->select('variable', 'v')
37 ->fields('v', ['name', 'value'])
38 ->condition('v.name', $variables, 'IN')
41 foreach ($node_types as $node_type) {
42 $name = 'upload_' . $node_type;
43 // By default, file attachments in D6 are enabled unless upload_<type> is
44 // false, so include types where the upload-variable is not set.
45 $enabled = !isset($values[$name]) || unserialize($values[$name]);
47 $return[$node_type]['node_type'] = $node_type;
48 $return[$node_type]['max_filesize'] = $max_filesize;
49 $return[$node_type]['file_extensions'] = $file_extensions;
53 return new \ArrayIterator($return);
59 public function getIds() {
70 public function fields() {
72 'node_type' => $this->t('Node type'),
73 'max_filesize' => $this->t('Max filesize'),
74 'file_extensions' => $this->t('File extensions'),
81 public function count($refresh = FALSE) {
82 return count($this->initializeIterator());