diff -u b/src/Plugin/Action/VboExportBase.php b/src/Plugin/Action/VboExportBase.php --- b/src/Plugin/Action/VboExportBase.php +++ b/src/Plugin/Action/VboExportBase.php @@ -7,6 +7,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\Core\Link; @@ -21,26 +22,36 @@ const EXTENSION = ''; - const DEFAULT_SCHEME = 'private'; - /** - * @var RendererInterface + * The renderer service. + * + * @var \Drupal\Core\Render\RendererInterface */ protected $renderer; /** - * @var StreamWrapperManagerInterface + * The stream wrapper manager service. + * + * @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface */ protected $streamWrapperManager; /** + * Default file scheme. + * + * @var string + */ + protected $defaultScheme; + + /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer, StreamWrapperManagerInterface $streamWrapperManager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, RendererInterface $renderer, StreamWrapperManagerInterface $streamWrapperManager, ConfigFactoryInterface $configFactory) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->renderer = $renderer; $this->streamWrapperManager = $streamWrapperManager; + $this->defaultScheme = $configFactory->get('system.file')->get('default_scheme'); } /** @@ -52,7 +63,8 @@ $plugin_id, $plugin_definition, $container->get('renderer'), - $container->get('stream_wrapper_manager') + $container->get('stream_wrapper_manager'), + $container->get('config.factory') ); } @@ -61,13 +73,14 @@ */ public function buildPreConfigurationForm(array $form, array $values, FormStateInterface $form_state) { $file_schemes = $this->streamWrapperManager->getNames(); - $form['file_scheme'] = array( + + $form['file_scheme'] = [ '#type' => 'radios', '#title' => $this->t('File Scheme'), '#description' => $this->t('The file scheme which the generated export file will be saved to.'), - '#default_value' => isset($values['file_scheme']) ? $values['file_scheme'] : static::DEFAULT_SCHEME, + '#default_value' => isset($values['file_scheme']) ? $values['file_scheme'] : $this->defaultScheme, '#options' => $file_schemes, - ); + ]; $form['strip_tags'] = [ '#title' => $this->t('Strip HTML tags'), @@ -118,7 +131,7 @@ $file->save(); $file_url = Url::fromUri(file_create_url($file->getFileUri())); $link = Link::fromTextAndUrl($this->t('Click here'), $file_url); - drupal_set_message($this->t('Export file created, @link to download.', array('@link' => $link->toString()))); + drupal_set_message($this->t('Export file created, @link to download.', ['@link' => $link->toString()])); } }