Commit 1aac0607 authored by swatichouhan012's avatar swatichouhan012 Committed by chr.fritsch

Issue #3121925 by swatichouhan012: \Drupal calls should be avoided in classes,...

Issue #3121925 by swatichouhan012: \Drupal calls should be avoided in classes, use dependency injection instead
parent 5fd2c222
......@@ -14,6 +14,7 @@ use Drupal\Core\Utility\Token;
use Drupal\dropzonejs\DropzoneJsUploadSaveInterface;
use Drupal\entity_browser\WidgetBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Asset\LibraryDiscoveryInterface;
/**
* Provides an Entity Browser widget that uploads new files.
......@@ -55,6 +56,13 @@ class DropzoneJsEbWidget extends WidgetBase {
*/
protected $fileSystem;
/**
* The library discovery service.
*
* @var \Drupal\Core\Asset\LibraryDiscoveryInterface
*/
protected $libraryDiscovery;
/**
* {@inheritdoc}
*/
......@@ -64,6 +72,7 @@ class DropzoneJsEbWidget extends WidgetBase {
$widget->setCurrentUser($container->get('current_user'));
$widget->setToken($container->get('token'));
$widget->setFileSystem($container->get('file_system'));
$widget->setLibraryDiscovery($container->get('library.discovery'));
return $widget;
}
......@@ -108,6 +117,16 @@ class DropzoneJsEbWidget extends WidgetBase {
$this->fileSystem = $fileSystem;
}
/**
* Set the Library Discovery service.
*
* @param \Drupal\Core\Asset\LibraryDiscoveryInterface $library_discovery
* The library discovery service.
*/
protected function setLibraryDiscovery(LibraryDiscoveryInterface $library_discovery) {
$this->libraryDiscovery = $library_discovery;
}
/**
* {@inheritdoc}
*/
......@@ -391,7 +410,7 @@ class DropzoneJsEbWidget extends WidgetBase {
];
$exif_found = \Drupal::service('library.discovery')->getLibraryByName('dropzonejs', 'exif-js');
$exif_found = $this->libraryDiscovery->getLibraryByName('dropzonejs', 'exif-js');
$form['clientside_resize'] = [
'#type' => 'checkbox',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment