class HotjarSettings in Hotjar 8
Same name and namespace in other branches
- 8.2 src/HotjarSettings.php \Drupal\hotjar\HotjarSettings
Class HotjarSettings.
@package Drupal\hotjar
Hierarchy
- class \Drupal\hotjar\HotjarSettings implements ContainerInjectionInterface, HotjarSettingsInterface
Expanded class hierarchy of HotjarSettings
1 string reference to 'HotjarSettings'
1 service uses HotjarSettings
File
- src/
HotjarSettings.php, line 14
Namespace
Drupal\hotjarView source
class HotjarSettings implements HotjarSettingsInterface, ContainerInjectionInterface {
const HOTJAR_PAGES = "/admin\n/admin/*\n/batch\n/node/add*\n/node/*/*\n/user/*/*";
/**
* Hotjar config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* Settings.
*
* @var array
*/
protected $settings;
/**
* HotjarSettings constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* Config factory.
*/
public function __construct(ConfigFactoryInterface $configFactory) {
$this->config = $configFactory
->get('hotjar.settings');
$this
->getSettings();
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
public function getSettings() {
if (!$this->settings) {
$settings = (array) $this->config
->getOriginal();
$settings += [
'account' => NULL,
'snippet_version' => 6,
'visibility_pages' => 0,
'pages' => static::HOTJAR_PAGES,
'visibility_roles' => 0,
'roles' => [],
];
if (empty($settings['snippet_version'])) {
$settings['snippet_version'] = 6;
}
$this->settings = $settings;
}
return $this->settings;
}
/**
* {@inheritdoc}
*/
public function getSetting($key, $default = NULL) {
$this
->getSettings();
return array_key_exists($key, $this->settings) ? $this->settings[$key] : $default;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HotjarSettings:: |
protected | property | Hotjar config. | |
HotjarSettings:: |
protected | property | Settings. | |
HotjarSettings:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
HotjarSettings:: |
public | function |
Get setting. Overrides HotjarSettingsInterface:: |
|
HotjarSettings:: |
public | function |
Get all settings. Overrides HotjarSettingsInterface:: |
|
HotjarSettings:: |
constant | |||
HotjarSettings:: |
public | function | HotjarSettings constructor. |