class UploadInstance
Same name and namespace in other branches
- 10 core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php \Drupal\file\Plugin\migrate\source\d6\UploadInstance
- 11.x core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php \Drupal\file\Plugin\migrate\source\d6\UploadInstance
- 8.9.x core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php \Drupal\file\Plugin\migrate\source\d6\UploadInstance
Drupal 6 upload instance source from database.
For available configuration keys, refer to the parent classes.
Plugin annotation
@MigrateSource(
id = "d6_upload_instance",
source_module = "upload"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase implements \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface extends \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
- class \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase implements \Drupal\Component\Plugin\DependentPluginInterface uses \Drupal\Core\Entity\DependencyTrait extends \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\file\Plugin\migrate\source\d6\UploadInstance uses \Drupal\migrate\Plugin\migrate\source\DummyQueryTrait extends \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
- class \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase implements \Drupal\Component\Plugin\DependentPluginInterface uses \Drupal\Core\Entity\DependencyTrait extends \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface extends \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase implements \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of UploadInstance
See also
\Drupal\migrate\Plugin\migrate\source\SqlBase
\Drupal\migrate\Plugin\migrate\source\SourcePluginBase
File
-
core/
modules/ file/ src/ Plugin/ migrate/ source/ d6/ UploadInstance.php, line 23
Namespace
Drupal\file\Plugin\migrate\source\d6View source
class UploadInstance extends DrupalSqlBase {
use DummyQueryTrait;
/**
* {@inheritdoc}
*/
protected function initializeIterator() {
$node_types = $this->select('node_type', 'nt')
->fields('nt', [
'type',
])
->execute()
->fetchCol();
$variables = array_map(function ($type) {
return 'upload_' . $type;
}, $node_types);
$max_filesize = $this->variableGet('upload_uploadsize_default', 1);
$max_filesize = $max_filesize ? $max_filesize . 'MB' : '';
$file_extensions = $this->variableGet('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
$return = [];
$values = $this->select('variable', 'v')
->fields('v', [
'name',
'value',
])
->condition('v.name', $variables, 'IN')
->execute()
->fetchAllKeyed();
foreach ($node_types as $node_type) {
$name = 'upload_' . $node_type;
// By default, file attachments in D6 are enabled unless upload_<type> is
// false, so include types where the upload-variable is not set.
$enabled = !isset($values[$name]) || unserialize($values[$name]);
if ($enabled) {
$return[$node_type]['node_type'] = $node_type;
$return[$node_type]['max_filesize'] = $max_filesize;
$return[$node_type]['file_extensions'] = $file_extensions;
}
}
return new \ArrayIterator($return);
}
/**
* {@inheritdoc}
*/
public function getIds() {
return [
'node_type' => [
'type' => 'string',
],
];
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'node_type' => $this->t('Node type'),
'max_filesize' => $this->t('Max filesize'),
'file_extensions' => $this->t('File extensions'),
];
}
/**
* {@inheritdoc}
*/
protected function doCount() {
return count($this->initializeIterator());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.