public function GoogleAnalyticsAccounts::__construct in Google Analytics 4.x
Constructor.
Parameters
\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory service.
\Drupal\Core\PrivateKey $private_key: The private key service.
File
- src/
Helpers/ GoogleAnalyticsAccounts.php, line 38
Class
Namespace
Drupal\google_analytics\HelpersCode
public function __construct(ConfigFactoryInterface $config_factory, PrivateKey $private_key) {
$this->config = $config_factory
->get('google_analytics.settings');
$accounts = $this->config
->get('account');
// Create the accounts array from either a single gtag id or multiple ones.
if (strpos($accounts, ',') === FALSE) {
$this->accounts[] = $accounts;
}
else {
$this->accounts = explode(',', $accounts);
}
$this->privateKey = $private_key
->get();
}