Loading src/Form/SettingsForm.php +16 −8 Original line number Diff line number Diff line Loading @@ -4,12 +4,12 @@ namespace Drupal\siteimprove\Form; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormStateInterface; use GuzzleHttp\Client; use Drupal\Core\Messenger\Messenger; use Drupal\siteimprove\Plugin\SiteimproveDomainManager; use Drupal\siteimprove\SiteimproveUtils; use Drupal\taxonomy\Entity\Vocabulary; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Serialization\Json; use Drupal\Core\Cache\Cache; Loading Loading @@ -49,16 +49,24 @@ class SettingsForm extends ConfigFormBase { */ protected $httpClient; /** * The vocabulary storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $vocabularyStorage; /** * {@inheritdoc} */ public function __construct(ConfigFactoryInterface $config_factory, SiteimproveUtils $siteimprove, SiteimproveDomainManager $pluginManagerSiteimproveDomain, Messenger $messenger, Client $httpClient) { public function __construct(ConfigFactoryInterface $config_factory, SiteimproveUtils $siteimprove, SiteimproveDomainManager $pluginManagerSiteimproveDomain, Messenger $messenger, Client $httpClient, EntityStorageInterface $vocabulary_storage) { parent::__construct($config_factory); $this->siteimprove = $siteimprove; $this->pluginManagerSiteimproveDomain = $pluginManagerSiteimproveDomain; $this->messenger = $messenger; $this->httpClient = $httpClient; $this->vocabularyStorage = $vocabulary_storage; } /** Loading @@ -71,7 +79,8 @@ class SettingsForm extends ConfigFormBase { $container->get('siteimprove.utils'), $container->get('plugin.manager.siteimprove_domain'), $container->get('messenger'), $container->get('http_client') $container->get('http_client'), $container->get('entity_type.manager')->getStorage('taxonomy_vocabulary') ); } Loading Loading @@ -183,7 +192,7 @@ class SettingsForm extends ConfigFormBase { $form['prepublish']['api_username'] = [ '#type' => 'textfield', '#description' => 'SiteImprove API username', '#description' => $this->t('SiteImprove API username'), '#default_value' => $config->get('api_username'), '#states' => [ 'enabled' => [ Loading @@ -196,7 +205,7 @@ class SettingsForm extends ConfigFormBase { $form['prepublish']['api_key'] = [ '#type' => 'textfield', '#description' => 'SiteImprove API key', '#description' => $this->t('SiteImprove API key'), '#default_value' => $config->get('api_key'), '#states' => [ 'enabled' => [ Loading Loading @@ -289,10 +298,9 @@ class SettingsForm extends ConfigFormBase { ], ], ]; $vocabulary_names = taxonomy_vocabulary_get_names(); $vocabularies = Vocabulary::loadMultiple($vocabulary_names); $taxonomy_options = []; foreach ($vocabularies as $vocabulary) { foreach ($this->vocabularyStorage->loadMultiple() as $vocabulary) { $taxonomy_options[$vocabulary->id()] = $vocabulary->label(); } $form['prepublish']['taxonomies']['enabled_taxonomies'] = [ Loading Loading
src/Form/SettingsForm.php +16 −8 Original line number Diff line number Diff line Loading @@ -4,12 +4,12 @@ namespace Drupal\siteimprove\Form; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Form\FormStateInterface; use GuzzleHttp\Client; use Drupal\Core\Messenger\Messenger; use Drupal\siteimprove\Plugin\SiteimproveDomainManager; use Drupal\siteimprove\SiteimproveUtils; use Drupal\taxonomy\Entity\Vocabulary; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Component\Serialization\Json; use Drupal\Core\Cache\Cache; Loading Loading @@ -49,16 +49,24 @@ class SettingsForm extends ConfigFormBase { */ protected $httpClient; /** * The vocabulary storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $vocabularyStorage; /** * {@inheritdoc} */ public function __construct(ConfigFactoryInterface $config_factory, SiteimproveUtils $siteimprove, SiteimproveDomainManager $pluginManagerSiteimproveDomain, Messenger $messenger, Client $httpClient) { public function __construct(ConfigFactoryInterface $config_factory, SiteimproveUtils $siteimprove, SiteimproveDomainManager $pluginManagerSiteimproveDomain, Messenger $messenger, Client $httpClient, EntityStorageInterface $vocabulary_storage) { parent::__construct($config_factory); $this->siteimprove = $siteimprove; $this->pluginManagerSiteimproveDomain = $pluginManagerSiteimproveDomain; $this->messenger = $messenger; $this->httpClient = $httpClient; $this->vocabularyStorage = $vocabulary_storage; } /** Loading @@ -71,7 +79,8 @@ class SettingsForm extends ConfigFormBase { $container->get('siteimprove.utils'), $container->get('plugin.manager.siteimprove_domain'), $container->get('messenger'), $container->get('http_client') $container->get('http_client'), $container->get('entity_type.manager')->getStorage('taxonomy_vocabulary') ); } Loading Loading @@ -183,7 +192,7 @@ class SettingsForm extends ConfigFormBase { $form['prepublish']['api_username'] = [ '#type' => 'textfield', '#description' => 'SiteImprove API username', '#description' => $this->t('SiteImprove API username'), '#default_value' => $config->get('api_username'), '#states' => [ 'enabled' => [ Loading @@ -196,7 +205,7 @@ class SettingsForm extends ConfigFormBase { $form['prepublish']['api_key'] = [ '#type' => 'textfield', '#description' => 'SiteImprove API key', '#description' => $this->t('SiteImprove API key'), '#default_value' => $config->get('api_key'), '#states' => [ 'enabled' => [ Loading Loading @@ -289,10 +298,9 @@ class SettingsForm extends ConfigFormBase { ], ], ]; $vocabulary_names = taxonomy_vocabulary_get_names(); $vocabularies = Vocabulary::loadMultiple($vocabulary_names); $taxonomy_options = []; foreach ($vocabularies as $vocabulary) { foreach ($this->vocabularyStorage->loadMultiple() as $vocabulary) { $taxonomy_options[$vocabulary->id()] = $vocabulary->label(); } $form['prepublish']['taxonomies']['enabled_taxonomies'] = [ Loading