Skip to content
Snippets Groups Projects

Issue #3217949 - Drupal 9 Support

6 files
+ 66
10
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 31
3
@@ -7,13 +7,41 @@
namespace Drupal\easychart\Form;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class OptionsForm extends FormBase {
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* OptionsForm constructor.
*
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file handler.
*/
public function __construct(FileSystemInterface $file_system = NULL) {
$this->fileSystem = $file_system;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('file_system')
);
}
/**
* {@inheritdoc}
*/
@@ -94,11 +122,11 @@ class OptionsForm extends FormBase {
}
// Write to file.
file_unmanaged_save_data(json_encode($current_options), 'public://easychart-options.json', FILE_EXISTS_REPLACE);
drupal_set_message($this->t('The configuration options have been saved.'));
$this->fileSystem->saveData(json_encode($current_options), 'public://easychart-options.json', FileSystemInterface::EXISTS_REPLACE);
$this->messenger()->addMessage($this->t('The configuration options have been saved.'));
}
else {
drupal_set_message($this->t('Something went wrong saving the options.'));
$this->messenger()->addMessage($this->t('Something went wrong saving the options.'));
}
}
Loading