Skip to content
Snippets Groups Projects

Issue #3291408: Drupal Coding Standard As Per Phpcs --Standard=DrupalPractice.

Files
3
+ 16
4
@@ -5,7 +5,7 @@ namespace Drupal\taxonomy_import\Form;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Config\ConfigFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -23,18 +23,29 @@ class ImportForm extends FormBase {
*/
protected $config;
/**
* The vocabulary storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $vocabularyStorage;
/**
* {@inheritdoc}
*/
public function __construct(ConfigFactoryInterface $config_factory) {
public function __construct(ConfigFactoryInterface $config_factory, EntityStorageInterface $vocabulary_storage) {
$this->config = $config_factory->get('taxonomy_import.config');
$this->vocabularyStorage = $vocabulary_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('config.factory'));
return new static(
$container->get('config.factory'),
$container->get('entity_type.manager')->getStorage('taxonomy_vocabulary'),
);
}
/**
@@ -45,11 +56,12 @@ class ImportForm extends FormBase {
}
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$vocabularies = Vocabulary::loadMultiple();
$vocabularies = $this->vocabularyStorage->loadMultiple();
$vocabulariesList = [];
foreach ($vocabularies as $vid => $vocablary) {
$vocabulariesList[$vid] = $vocablary->get('name');
Loading