diff --git a/dvf_ckan/src/Plugin/Visualisation/Source/CkanResource.php b/dvf_ckan/src/Plugin/Visualisation/Source/CkanResource.php
index 50bffe9..120c068 100644
--- a/dvf_ckan/src/Plugin/Visualisation/Source/CkanResource.php
+++ b/dvf_ckan/src/Plugin/Visualisation/Source/CkanResource.php
@@ -6,6 +6,7 @@
use Drupal\ckan_connect\Parser\CkanResourceUrlParserInterface;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\dvf\DvfHelpers;
use Drupal\dvf\Plugin\VisualisationInterface;
@@ -96,6 +97,8 @@ class CkanResource extends VisualisationSourceBase implements ContainerFactoryPl
* The CKAN resource URL parser.
* @param \Drupal\dvf\DvfHelpers $dvf_helpers
* The DVF helpers.
+ * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
+ * The file URL generator.
*/
public function __construct(
array $configuration,
@@ -108,9 +111,10 @@ public function __construct(
CacheBackendInterface $cache,
CkanClientInterface $ckan_client,
CkanResourceUrlParserInterface $ckan_resource_url_parser,
- DvfHelpers $dvf_helpers
+ DvfHelpers $dvf_helpers,
+ FileUrlGeneratorInterface $file_url_generator
) {
- parent::__construct($configuration, $plugin_id, $plugin_definition, $visualisation, $module_handler, $logger, $http_client);
+ parent::__construct($configuration, $plugin_id, $plugin_definition, $visualisation, $module_handler, $logger, $http_client, $file_url_generator);
$this->cache = $cache;
$this->ckanClient = $ckan_client;
$this->ckanResourceUrlParser = $ckan_resource_url_parser;
@@ -152,7 +156,8 @@ public static function create(
$container->get('cache.dvf_ckan'),
$container->get('ckan_connect.client'),
$container->get('ckan_connect.resource_url_parser'),
- $container->get('dvf.helpers')
+ $container->get('dvf.helpers'),
+ $container->get('file_url_generator')
);
}
diff --git a/dvf_csv/src/Plugin/Visualisation/Source/CsvFile.php b/dvf_csv/src/Plugin/Visualisation/Source/CsvFile.php
index 99e8ae8..aa1406c 100644
--- a/dvf_csv/src/Plugin/Visualisation/Source/CsvFile.php
+++ b/dvf_csv/src/Plugin/Visualisation/Source/CsvFile.php
@@ -4,6 +4,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\dvf\Plugin\VisualisationInterface;
@@ -67,6 +68,8 @@ class CsvFile extends VisualisationSourceBase implements ContainerFactoryPluginI
* The HTTP client.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The cache backend.
+ * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
+ * The file URL generator.
*/
public function __construct(
array $configuration,
@@ -76,9 +79,10 @@ public function __construct(
ModuleHandlerInterface $module_handler,
LoggerInterface $logger,
Client $http_client,
- CacheBackendInterface $cache
+ CacheBackendInterface $cache,
+ FileUrlGeneratorInterface $file_url_generator
) {
- parent::__construct($configuration, $plugin_id, $plugin_definition, $visualisation, $module_handler, $logger, $http_client);
+ parent::__construct($configuration, $plugin_id, $plugin_definition, $visualisation, $module_handler, $logger, $http_client, $file_url_generator);
$this->cache = $cache;
}
@@ -108,7 +112,8 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('module_handler'),
$container->get('logger.channel.dvf'),
$container->get('http_client'),
- $container->get('cache.dvf_csv')
+ $container->get('cache.dvf_csv'),
+ $container->get('file_url_generator')
);
}
diff --git a/dvf_json/src/Plugin/Visualisation/Source/JsonFile.php b/dvf_json/src/Plugin/Visualisation/Source/JsonFile.php
index 26cffba..e4fa958 100644
--- a/dvf_json/src/Plugin/Visualisation/Source/JsonFile.php
+++ b/dvf_json/src/Plugin/Visualisation/Source/JsonFile.php
@@ -4,6 +4,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\dvf\DvfHelpers;
@@ -78,6 +79,8 @@ class JsonFile extends VisualisationSourceBase implements ContainerFactoryPlugin
* The cache backend.
* @param \Drupal\dvf\DvfHelpers $dvf_helpers
* The DVF helpers.
+ * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
+ * The file URL generator.
*/
public function __construct(
array $configuration,
@@ -88,9 +91,10 @@ public function __construct(
LoggerInterface $logger,
Client $http_client,
CacheBackendInterface $cache,
- DvfHelpers $dvf_helpers
+ DvfHelpers $dvf_helpers,
+ FileUrlGeneratorInterface $file_url_generator
) {
- parent::__construct($configuration, $plugin_id, $plugin_definition, $visualisation, $module_handler, $logger, $http_client);
+ parent::__construct($configuration, $plugin_id, $plugin_definition, $visualisation, $module_handler, $logger, $http_client, $file_url_generator);
$this->cache = $cache;
$this->dvfHelpers = $dvf_helpers;
}
@@ -122,7 +126,8 @@ public static function create(ContainerInterface $container, array $configuratio
$container->get('logger.channel.dvf'),
$container->get('http_client'),
$container->get('cache.dvf_json'),
- $container->get('dvf.helpers')
+ $container->get('dvf.helpers'),
+ $container->get('file_url_generator')
);
}
@@ -191,7 +196,7 @@ public function getRecords() {
}
foreach ($this->getFields() as $field_key => $field_label) {
- foreach ($json->data() as $record_id => $record) {
+ foreach ($json->getData() as $record_id => $record) {
if (!isset($records[$record_id])) {
$records[$record_id] = new \stdClass();
}
diff --git a/src/Controller/DvfHelpController.php b/src/Controller/DvfHelpController.php
index ffe9a55..58ef751 100644
--- a/src/Controller/DvfHelpController.php
+++ b/src/Controller/DvfHelpController.php
@@ -3,13 +3,53 @@
namespace Drupal\dvf\Controller;
use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Extension\ModuleExtensionList;
+use Drupal\Core\Render\RendererInterface;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provide information for DvfHelp page.
*/
class DvfHelpController extends ControllerBase {
+ /**
+ * The module extension list.
+ *
+ * @var \Drupal\Core\Extension\ModuleExtensionList
+ */
+ protected $moduleExtensionList;
+
+ /**
+ * The renderer service.
+ *
+ * @var \Drupal\Core\Render\RendererInterface
+ */
+ protected $renderer;
+
+ /**
+ * Constructs a new DvfHelpController object.
+ *
+ * @param \Drupal\Core\Extension\ModuleExtensionList $extension_list_module
+ * The module extension list.
+ * @param \Drupal\Core\Render\RendererInterface $renderer
+ * The renderer service.
+ */
+ public function __construct(ModuleExtensionList $extension_list_module, RendererInterface $renderer) {
+ $this->moduleExtensionList = $extension_list_module;
+ $this->renderer = $renderer;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('extension.list.module'),
+ $container->get('renderer')
+ );
+ }
+
/**
* Returns the help page information ready to load in partial twig template.
*
@@ -21,7 +61,7 @@ class DvfHelpController extends ControllerBase {
*/
public function helpPage($topic) {
- $dvf_path = drupal_get_path('module', 'dvf');
+ $dvf_path = $this->moduleExtensionList->getPath('dvf');
$file_path = $dvf_path . '/templates/help/';
$css_path = base_path() . $dvf_path . '/css/help.css';
@@ -38,7 +78,7 @@ public function helpPage($topic) {
'#css' => $css_path,
];
- $output = \Drupal::service('renderer')->renderRoot($build);
+ $output = $this->renderer->renderRoot($build);
$response = new Response();
return $response->setContent($output);
diff --git a/src/Plugin/Field/FieldType/VisualisationFileItem.php b/src/Plugin/Field/FieldType/VisualisationFileItem.php
index 99b6a4c..ca7585d 100644
--- a/src/Plugin/Field/FieldType/VisualisationFileItem.php
+++ b/src/Plugin/Field/FieldType/VisualisationFileItem.php
@@ -92,7 +92,7 @@ public function setValue($values, $notify = TRUE) {
}
if (is_string($values['options'])) {
- $values['options'] = unserialize($values['options']);
+ $values['options'] = unserialize($values['options'], ['allowed_classes' => FALSE]);
}
parent::setValue($values, $notify);
diff --git a/src/Plugin/Field/FieldType/VisualisationUrlItem.php b/src/Plugin/Field/FieldType/VisualisationUrlItem.php
index 8239771..10fea58 100644
--- a/src/Plugin/Field/FieldType/VisualisationUrlItem.php
+++ b/src/Plugin/Field/FieldType/VisualisationUrlItem.php
@@ -110,7 +110,7 @@ public function setValue($values, $notify = TRUE) {
}
if (is_string($values['options'])) {
- $values['options'] = unserialize($values['options']);
+ $values['options'] = unserialize($values['options'], ['allowed_classes' => FALSE]);
}
parent::setValue($values, $notify);
diff --git a/src/Plugin/Field/FieldWidget/VisualisationFileWidget.php b/src/Plugin/Field/FieldWidget/VisualisationFileWidget.php
index 29fd276..b0e1472 100644
--- a/src/Plugin/Field/FieldWidget/VisualisationFileWidget.php
+++ b/src/Plugin/Field/FieldWidget/VisualisationFileWidget.php
@@ -2,11 +2,15 @@
namespace Drupal\dvf\Plugin\Field\FieldWidget;
+use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\RendererInterface;
use Drupal\dvf\FieldWidgetTrait;
+use Drupal\dvf\Plugin\VisualisationManager;
use Drupal\file\Element\ManagedFile;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Plugin implementation of the 'dvf_file_default' field widget.
@@ -23,6 +27,36 @@ class VisualisationFileWidget extends WidgetBase {
use FieldWidgetTrait;
+ /**
+ * The visualisation manager.
+ *
+ * @var \Drupal\dvf\Plugin\VisualisationManager
+ */
+ protected $visualisationManager;
+
+ /**
+ * The renderer service.
+ *
+ * @var \Drupal\Core\Render\RendererInterface
+ */
+ protected $renderer;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, VisualisationManager $visualisationManager, RendererInterface $renderer) {
+ parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
+ $this->visualisationManager = $visualisationManager;
+ $this->renderer = $renderer;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('plugin.manager.visualisation'), $container->get('renderer'));
+ }
+
/**
* {@inheritdoc}
*/
@@ -50,7 +84,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
'#cardinality' => $cardinality,
];
- $element['file']['#description'] = \Drupal::service('renderer')->renderPlain($file_upload_help);
+ $element['file']['#description'] = $this->renderer->renderPlain($file_upload_help);
// Default value for managed file expects an array of fids.
if (!empty($values[$delta]['file'])) {
@@ -72,7 +106,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
'#options' => $this->getVisualisationStyleOptions(),
'#empty_option' => $this->t('- Select -'),
'#empty_value' => '',
- '#default_value' => isset($items[$delta]->options['visualisation_style']) ? $items[$delta]->options['visualisation_style'] : '',
+ '#default_value' => $items[$delta]->options['visualisation_style'] ?? '',
'#required' => $element['#required'],
'#ajax' => [
'callback' => [$this, 'updateVisualisationOptions'],
@@ -164,9 +198,6 @@ public static function value(array $element, $input, FormStateInterface $form_st
protected function getVisualisationPlugin(FieldItemListInterface $items, $delta, array $form, FormStateInterface $form_state) {
$values = $this->getFieldValue($items, $delta, $form, $form_state);
- /** @var \Drupal\dvf\Plugin\VisualisationManagerInterface $plugin_manager */
- $plugin_manager = \Drupal::service('plugin.manager.visualisation');
-
$plugin_id = $this->fieldDefinition->getType();
$plugin_configuration = [
'options' => [
@@ -196,10 +227,7 @@ protected function getVisualisationPlugin(FieldItemListInterface $items, $delta,
$plugin_configuration['style']['options'] = $values[$delta]['options']['visualisation_style_options'];
}
- /** @var \Drupal\dvf\Plugin\VisualisationInterface $plugin */
- $plugin = $plugin_manager->createInstance($plugin_id, $plugin_configuration);
-
- return $plugin;
+ return $this->visualisationManager->createInstance($plugin_id, $plugin_configuration);
}
}
diff --git a/src/Plugin/Field/FieldWidget/VisualisationUrlWidget.php b/src/Plugin/Field/FieldWidget/VisualisationUrlWidget.php
index 4efbbda..642b71a 100644
--- a/src/Plugin/Field/FieldWidget/VisualisationUrlWidget.php
+++ b/src/Plugin/Field/FieldWidget/VisualisationUrlWidget.php
@@ -2,10 +2,13 @@
namespace Drupal\dvf\Plugin\Field\FieldWidget;
+use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\dvf\FieldWidgetTrait;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\dvf\Plugin\VisualisationManager;
/**
* Plugin implementation of the 'dvf_url_default' field widget.
@@ -22,6 +25,28 @@ class VisualisationUrlWidget extends WidgetBase {
use FieldWidgetTrait;
+ /**
+ * The visualisation manager.
+ *
+ * @var \Drupal\dvf\Plugin\VisualisationManager
+ */
+ protected $visualisationManager;
+
+ /**
+ * {@inheritdoc}
+ */
+ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, VisualisationManager $visualisationManager) {
+ parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
+ $this->visualisationManager = $visualisationManager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('plugin.manager.visualisation'));
+ }
+
/**
* {@inheritdoc}
*/
@@ -33,7 +58,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
'#type' => 'url',
'#title' => $this->t('URL'),
'#description' => $this->t('External url to dataset.'),
- '#default_value' => isset($items[$delta]->uri) ? $items[$delta]->uri : NULL,
+ '#default_value' => $items[$delta]->uri ?? NULL,
'#maxlength' => 2048,
'#required' => $element['#required'],
];
@@ -52,7 +77,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
'#options' => $this->getVisualisationStyleOptions(),
'#empty_option' => $this->t('- Select -'),
'#empty_value' => '',
- '#default_value' => isset($items[$delta]->options['visualisation_style']) ? $items[$delta]->options['visualisation_style'] : '',
+ '#default_value' => $items[$delta]->options['visualisation_style'] ?? '',
'#required' => $element['#required'],
'#ajax' => [
'callback' => [$this, 'updateVisualisationOptions'],
@@ -95,9 +120,6 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
protected function getVisualisationPlugin(FieldItemListInterface $items, $delta, array $form, FormStateInterface $form_state) {
$values = $this->getFieldValue($items, $delta, $form, $form_state);
- /** @var \Drupal\dvf\Plugin\VisualisationManagerInterface $plugin_manager */
- $plugin_manager = \Drupal::service('plugin.manager.visualisation');
-
$plugin_id = $this->fieldDefinition->getType();
$plugin_configuration = [
'options' => [
@@ -122,10 +144,7 @@ protected function getVisualisationPlugin(FieldItemListInterface $items, $delta,
$plugin_configuration['style']['options'] = $values[$delta]['options']['visualisation_style_options'];
}
- /** @var \Drupal\dvf\Plugin\VisualisationInterface $plugin */
- $plugin = $plugin_manager->createInstance($plugin_id, $plugin_configuration);
-
- return $plugin;
+ return $this->visualisationManager->createInstance($plugin_id, $plugin_configuration);
}
}
diff --git a/src/Plugin/Visualisation/Source/VisualisationSourceBase.php b/src/Plugin/Visualisation/Source/VisualisationSourceBase.php
index 47d6591..1e28c33 100644
--- a/src/Plugin/Visualisation/Source/VisualisationSourceBase.php
+++ b/src/Plugin/Visualisation/Source/VisualisationSourceBase.php
@@ -18,6 +18,7 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
+use Drupal\Core\File\FileUrlGeneratorInterface;
/**
* Provides a base class for VisualisationSource plugins.
@@ -63,6 +64,13 @@ abstract class VisualisationSourceBase extends PluginBase implements Visualisati
*/
protected $iterator;
+ /**
+ * The file URL generator.
+ *
+ * @var \Drupal\Core\File\FileUrlGeneratorInterface
+ */
+ protected $fileUrlGenerator;
+
/**
* Constructs a new VisualisationSourceBase.
*
@@ -80,6 +88,8 @@ abstract class VisualisationSourceBase extends PluginBase implements Visualisati
* Instance of the logger object.
* @param \GuzzleHttp\Client $http_client
* The HTTP client.
+ * @param \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator
+ * The file URL generator.
*/
public function __construct(
array $configuration,
@@ -88,13 +98,20 @@ public function __construct(
VisualisationInterface $visualisation = NULL,
ModuleHandlerInterface $module_handler,
LoggerInterface $logger,
- Client $http_client
+ Client $http_client,
+ FileUrlGeneratorInterface $file_url_generator = NULL
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->visualisation = $visualisation;
$this->moduleHandler = $module_handler;
$this->logger = $logger;
$this->httpClient = $http_client;
+
+ if (!$file_url_generator) {
+ @trigger_error('Calling VisualisationSourceBase::__construct() without the $file_url_generator argument is deprecated in drupal:9.5.0 and the $file_url_generator argument will be required in drupal:10.0.0. See https://www.drupal.org/node/2940031', E_USER_DEPRECATED);
+ $file_url_generator = \Drupal::service('file_url_generator');
+ }
+ $this->fileUrlGenerator = $file_url_generator;
}
/**
@@ -120,7 +137,8 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id,
$plugin_definition,
$visualisation,
- $container->get('module_handler')
+ $container->get('module_handler'),
+ $container->get('file_url_generator')
);
}
@@ -239,7 +257,7 @@ public function getVisualisation() {
public function getDownloadUrl() {
$uri = $this->config('uri');
return ('dvf_file' === $this->visualisation->getPluginId())
- ? file_create_url($uri) : $uri;
+ ? $this->fileUrlGenerator->generateAbsoluteString($uri) : $uri;
}
/**
diff --git a/src/Plugin/Visualisation/Style/AxisChart.php b/src/Plugin/Visualisation/Style/AxisChart.php
index 1a4065a..d868815 100644
--- a/src/Plugin/Visualisation/Style/AxisChart.php
+++ b/src/Plugin/Visualisation/Style/AxisChart.php
@@ -223,7 +223,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
'values' => $this->t('Group by label values'),
],
'#default_value' => $this->config('axis', 'x', 'x_axis_grouping'),
- '#description' => t(
+ '#description' => $this->t(
'The X axis can use keys or the label key value as tick values. Changing this swaps what is displayed on the X axis (or table header if viewed as a table). Tick values field must be set for "labels" options to work correctly. @help.',
['@help' => $this->dvfHelpers->getHelpPageLink('x-axis-grouping')]),
'#ajax' => [
@@ -267,7 +267,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$form['axis']['x']['styles'] = [
'#type' => 'details',
'#title' => $this->t('X axis styles'),
- '#description' => t('Enter whole numbers (E.g. 320). Values are set as pixels unless otherwise indicated.
'),
+ '#description' => $this->t('Enter whole numbers (E.g. 320). Values are set as pixels unless otherwise indicated.
'),
'#tree' => TRUE,
];
@@ -395,7 +395,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$form['axis']['y']['styles'] = [
'#type' => 'details',
'#title' => $this->t('Y axis styles'),
- '#description' => t('Enter whole numbers (E.g. 320). Values are set as pixels unless otherwise indicated.
'),
+ '#description' => $this->t('Enter whole numbers (E.g. 320). Values are set as pixels unless otherwise indicated.
'),
'#tree' => TRUE,
];
@@ -457,13 +457,13 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$form['grid']['lines'] = [
'#type' => 'details',
'#title' => $this->t('Grid lines'),
- '#description' => t('Show additional grid lines along X or Y axis. @help',
+ '#description' => $this->t('Show additional grid lines along X or Y axis. @help',
['@help' => $this->dvfHelpers->getHelpPageLink('grid-lines')]),
'#open' => ($grid_lines_count > 0),
'#tree' => TRUE,
'#attributes' => [
'id' => Html::getUniqueId('dvf-options-grid-lines'),
- 'title' => t('E.g. If a dataset contains values between 1 & 40, indicate the average numeric value by adding a Y axis line with a value of 20, and a label "Average number".'),
+ 'title' => $this->t('E.g. If a dataset contains values between 1 & 40, indicate the average numeric value by adding a Y axis line with a value of 20, and a label "Average number".'),
],
];
@@ -568,14 +568,14 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$form['chart']['table']['disable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Disable fallback table'),
- '#description' => t('Disable the option to view data as a table via a "Show table" button'),
+ '#description' => $this->t('Disable the option to view data as a table via a "Show table" button'),
'#default_value' => $this->config('chart', 'table', 'disable'),
];
$form['chart']['table']['datatable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Fallback table uses datatables'),
- '#description' => t('Render the fallback table using datatables.js. This may reduce accessibility as Javascript is required'),
+ '#description' => $this->t('Render the fallback table using datatables.js. This may reduce accessibility as Javascript is required'),
'#default_value' => $this->config('chart', 'table', 'datatable'),
];
@@ -596,7 +596,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$form['chart']['styles'] = [
'#type' => 'details',
'#title' => $this->t('Chart styles'),
- '#description' => t('Enter whole numbers (E.g. 320). Values are set as pixels unless otherwise indicated.
'),
+ '#description' => $this->t('Enter whole numbers (E.g. 320). Values are set as pixels unless otherwise indicated.
'),
'#tree' => TRUE,
];
@@ -847,7 +847,7 @@ protected function chartBuildSettings(array $records) {
];
if (empty($records)) {
- $this->messenger->addError(t('Invalid records.'));
+ $this->messenger->addError($this->t('Invalid records.'));
return [];
}
diff --git a/src/Plugin/Visualisation/Style/VisualisationStyleBase.php b/src/Plugin/Visualisation/Style/VisualisationStyleBase.php
index f6472a8..0927b9f 100644
--- a/src/Plugin/Visualisation/Style/VisualisationStyleBase.php
+++ b/src/Plugin/Visualisation/Style/VisualisationStyleBase.php
@@ -234,8 +234,8 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#type' => 'details',
- '#title' => t('Column/Group overrides'),
- '#description' => '
' . t('Optionally override a style for a specific column, add one key|value per line and separate key value with a pipe. @help.
Examples: @examples.',
+ '#title' => $this->t('Column/Group overrides'),
+ '#description' => '
' . $this->t('Optionally override a style for a specific column, add one key|value per line and separate key value with a pipe. @help.
Examples: @examples.',
[
'@examples' => new FormattableMarkup(implode(' or ', $column_override_examples), []),
'@help' => $this->dvfHelpers->getHelpPageLink('column-overrides'),
@@ -258,22 +258,22 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
'#collapsed' => TRUE,
'#access' => ($this->getVisualisation()->getSourcePlugin()->getPluginId() === 'dvf_ckan_resource'),
'#type' => 'details',
- '#title' => t('CKAN data filters'),
- '#description' => t('Filters can be used to refine/reduce the records returned from the CKAN datasource. @help',
+ '#title' => $this->t('CKAN data filters'),
+ '#description' => $this->t('Filters can be used to refine/reduce the records returned from the CKAN datasource. @help',
['@help' => $this->dvfHelpers->getHelpPageLink('data-filters')]),
];
$form['data']['data_filters']['q'] = [
'#type' => 'textfield',
- '#title' => t('Full text query'),
- '#description' => t('Optionally query entire dataset for any string value.'),
+ '#title' => $this->t('Full text query'),
+ '#description' => $this->t('Optionally query entire dataset for any string value.'),
'#default_value' => $this->config('data', 'data_filters', 'q'),
];
$form['data']['data_filters']['filters'] = [
'#type' => 'textfield',
- '#title' => t('Filters'),
- '#description' => t('Filter on key/value dictionary. For example: {"code": "4000", "year": "2016"} or {"year": ["2014", "2015", "2015"]}. Case sensitive.'),
+ '#title' => $this->t('Filters'),
+ '#description' => $this->t('Filter on key/value dictionary. For example: {"code": "4000", "year": "2016"} or {"year": ["2014", "2015", "2015"]}. Case sensitive.'),
'#default_value' => $this->config('data', 'data_filters', 'filters'),
];
diff --git a/src/Plugin/Visualisation/VisualisationBase.php b/src/Plugin/Visualisation/VisualisationBase.php
index 39f1634..e409187 100644
--- a/src/Plugin/Visualisation/VisualisationBase.php
+++ b/src/Plugin/Visualisation/VisualisationBase.php
@@ -120,7 +120,7 @@ public function __construct(
$this->source = $configuration['source'];
$this->style = $configuration['style'];
$this->moduleHandler = $module_handler;
- $this->entity = isset($configuration['entity']) ? $configuration['entity'] : NULL;
+ $this->entity = $configuration['entity'] ?? NULL;
$this->themeManager = $themeManager;
}
diff --git a/src/Plugin/migrate/process/CkanConvertBlob.php b/src/Plugin/migrate/process/CkanConvertBlob.php
index c38e8ba..9d81f27 100644
--- a/src/Plugin/migrate/process/CkanConvertBlob.php
+++ b/src/Plugin/migrate/process/CkanConvertBlob.php
@@ -32,7 +32,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
return $value;
}
- $ckan_values = unserialize($value);
+ $ckan_values = unserialize($value, ['allowed_classes' => FALSE]);
$ckan_config = $ckan_values['visualisation_config'];
$visualisation_style = [
diff --git a/tests/src/Functional/Traits/DvfFileTrait.php b/tests/src/Functional/Traits/DvfFileTrait.php
index a00b5c5..bb6f4a3 100644
--- a/tests/src/Functional/Traits/DvfFileTrait.php
+++ b/tests/src/Functional/Traits/DvfFileTrait.php
@@ -53,7 +53,7 @@ protected function getDvfSampleFilePath($filename) {
* Full path to directory.
*/
protected function getDvfSampleDirFullPath() {
- return \Drupal::root() . '/' . drupal_get_path('module', 'dvf') . $this->dvfSampleDirPath;
+ return \Drupal::root() . '/' . \Drupal::service('extension.list.module')->getPath('dvf') . $this->dvfSampleDirPath;
}
/**