Skip to content
Snippets Groups Projects
Commit 55f17107 authored by baldwinlouie's avatar baldwinlouie Committed by Yas Naoi
Browse files

Issue #3177262 by baldwinlouie, yas: Fix dependency injection based 500 errors

parent 245c2e40
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@
namespace Drupal\k8s\Service;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\aws_cloud\Service\Pricing\InstanceTypePriceDataProvider;
/**
* Cost fields renderer service.
......@@ -17,36 +16,14 @@ class CostFieldsRenderer implements CostFieldsRendererInterface {
*/
protected $moduleHandler;
/**
* The data provider.
*
* @var Drupal\aws_cloud\Service\Pricing\InstanceTypePriceDataProvider
*/
protected $dataProvider;
/**
* Constructs a new CostFieldsRenderer object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\aws_cloud\Service\Pricing\InstanceTypePriceDataProvider $data_provider
* The aws cloud data provider.
*/
public function __construct(
ModuleHandlerInterface $module_handler,
InstanceTypePriceDataProvider $data_provider) {
public function __construct(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
$this->dataProvider = $data_provider;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('aws_cloud.instance_type_price_data_provider')
);
}
/**
......@@ -65,7 +42,9 @@ class CostFieldsRenderer implements CostFieldsRendererInterface {
return $build;
}
$price_date_provider = $this->data_provider;
// Do not change to dependency injection. Otherwise, it introduces
// a dependency on AWS Cloud module.
$price_date_provider = \Drupal::service('aws_cloud.instance_type_price_data_provider');
$fields = $price_date_provider->getFields();
$price_data = $price_date_provider->getDataByRegion($region, NULL, NULL, NULL, $refresh);
$price_info = [];
......
......@@ -587,7 +587,13 @@ class CloudService extends CloudServiceBase implements CloudServiceInterface {
if (!$this->moduleHandler->moduleExists('geocoder')) {
return;
}
$plugins = $this->geocoderProviderPluginManager->getDefinitions();
if (empty($this->geocoderProviderPluginManager)) {
// Do not use Dependency Injection during module installation.
$plugins = \Drupal::service('plugin.manager.geocoder.provider')->getDefinitions();
}
else {
$plugins = $this->geocoderProviderPluginManager->getDefinitions();
}
if (empty($plugins)) {
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment