class DefaultProcessor in Cookie Content Blocker 8
Class DefaultProcessor.
Applies defaults to the blocker element as configured in settings. Makes sure the element is wrapped as well.
@package Drupal\cookie_content_blocker\ElementProcessor
Hierarchy
- class \Drupal\cookie_content_blocker\ElementProcessor\ElementProcessorBase implements ElementProcessorInterface, TrustedCallbackInterface
- class \Drupal\cookie_content_blocker\ElementProcessor\DefaultProcessor
Expanded class hierarchy of DefaultProcessor
1 string reference to 'DefaultProcessor'
1 service uses DefaultProcessor
File
- src/
ElementProcessor/ DefaultProcessor.php, line 17
Namespace
Drupal\cookie_content_blocker\ElementProcessorView source
class DefaultProcessor extends ElementProcessorBase {
/**
* The config factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
private $configFactory;
/**
* Constructs a DefaultProcessor object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public function applies(array $element) : bool {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function processElement(array $element) : array {
$config = $this->configFactory
->get('cookie_content_blocker.settings');
$element['#theme_wrappers'] = $element['#theme_wrappers'] ?? [];
$element['#theme_wrappers'][] = 'cookie_content_blocker_wrapper';
if (!is_array($element['#cookie_content_blocker'])) {
$element['#cookie_content_blocker'] = [];
}
$defaults = [
'blocked_message' => $config
->get('blocked_message'),
'show_button' => $config
->get('show_button'),
'button_text' => $config
->get('button_text'),
'enable_click' => $config
->get('enable_click_consent_change'),
'show_placeholder' => TRUE,
'preview' => [],
];
$element['#cookie_content_blocker'] = array_merge($defaults, $element['#cookie_content_blocker']);
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultProcessor:: |
private | property | The config factory service. | |
DefaultProcessor:: |
public | function |
Declares if the route processor applies to the given element. Overrides ElementProcessorBase:: |
|
DefaultProcessor:: |
public | function |
Processes the element. Overrides ElementProcessorBase:: |
|
DefaultProcessor:: |
public | function | Constructs a DefaultProcessor object. | |
ElementProcessorBase:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |