Skip to content
Snippets Groups Projects
Commit 3ce5e04e authored by Fabio De Tant's avatar Fabio De Tant Committed by Tim Diels
Browse files

Issue #3276915 by dtfabio, tim-diels: Clean up ActiveCampaignApi service

parent b3c0303a
Branches
Tags
1 merge request!6Issue #3276915: Clean up ActiveCampaignApi service
services: services:
activecampaign.api: activecampaign.api:
class: Drupal\activecampaign\ActiveCampaignApi class: Drupal\activecampaign\ActiveCampaignApi
arguments: ['@config.storage'] arguments: ['@config.factory']
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace Drupal\activecampaign; namespace Drupal\activecampaign;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
/** /**
...@@ -18,6 +18,13 @@ class ActiveCampaignApi { ...@@ -18,6 +18,13 @@ class ActiveCampaignApi {
*/ */
protected $activeCampaignSDK; protected $activeCampaignSDK;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/** /**
* The url to active campaign. * The url to active campaign.
* *
...@@ -28,11 +35,12 @@ class ActiveCampaignApi { ...@@ -28,11 +35,12 @@ class ActiveCampaignApi {
/** /**
* Constructs an Api object. * Constructs an Api object.
* *
* @param \Drupal\Core\Config\StorageInterface $storage * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The active configuration storage. * The configuration factory.
*/ */
public function __construct(StorageInterface $storage) { public function __construct(ConfigFactoryInterface $config_factory) {
$config = \Drupal::config('activecampaign.settings'); $this->configFactory = $config_factory;
$config = $this->configFactory->get('activecampaign.settings');
$this->url = $config->get('url'); $this->url = $config->get('url');
$this->activeCampaignSDK = new \ActiveCampaign($config->get('api_url'), $config->get('api_key')); $this->activeCampaignSDK = new \ActiveCampaign($config->get('api_url'), $config->get('api_key'));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment