function TemporaryJsonapiFileFieldUploader::__construct

Same name in other branches
  1. 9 core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php \Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader::__construct()
  2. 8.9.x core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php \Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader::__construct()
  3. 10 core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php \Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader::__construct()

Constructs a FileUploadResource instance.

Parameters

\Psr\Log\LoggerInterface $logger: A logger instance.

\Drupal\Core\File\FileSystemInterface $file_system: The file system service.

\Symfony\Component\Mime\MimeTypeGuesserInterface $mime_type_guesser: The MIME type guesser.

\Drupal\Core\Utility\Token $token: The token replacement instance.

\Drupal\Core\Lock\LockBackendInterface $lock: The lock service.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory.

\Symfony\Contracts\EventDispatcher\EventDispatcherInterface|null $event_dispatcher: (optional) The event dispatcher.

\Drupal\file\Validation\FileValidatorInterface|null $file_validator: The file validator.

\Drupal\file\Upload\InputStreamFileWriterInterface|null $input_stream_file_writer: The stream file uploader.

File

core/modules/jsonapi/src/Controller/TemporaryJsonapiFileFieldUploader.php, line 158

Class

TemporaryJsonapiFileFieldUploader
Reads data from an upload stream and creates a corresponding file entity.

Namespace

Drupal\jsonapi\Controller

Code

public function __construct(LoggerInterface $logger, FileSystemInterface $file_system, $mime_type_guesser, Token $token, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, EventDispatcherInterface $event_dispatcher = NULL, FileValidatorInterface $file_validator = NULL, InputStreamFileWriterInterface $input_stream_file_writer = NULL) {
    $this->logger = $logger;
    $this->fileSystem = $file_system;
    $this->mimeTypeGuesser = $mime_type_guesser;
    $this->token = $token;
    $this->lock = $lock;
    $this->systemFileConfig = $config_factory->get('system.file');
    if (!$event_dispatcher) {
        $event_dispatcher = \Drupal::service('event_dispatcher');
    }
    $this->eventDispatcher = $event_dispatcher;
    if (!$file_validator) {
        @trigger_error('Calling ' . __METHOD__ . '() without the $file_validator argument is deprecated in drupal:10.2.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3363700', E_USER_DEPRECATED);
        $file_validator = \Drupal::service('file.validator');
    }
    $this->fileValidator = $file_validator;
    if (!$input_stream_file_writer) {
        @trigger_error('Calling ' . __METHOD__ . '() without the $input_stream_file_writer argument is deprecated in drupal:10.3.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3380607', E_USER_DEPRECATED);
        $input_stream_file_writer = \Drupal::service('file.input_stream_file_writer');
    }
    $this->inputStreamFileWriter = $input_stream_file_writer;
}

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