public function EloquaEventSubscriber::evaluateTrackingScope in Eloqua 8
Evaluates tracking scoping conditions and sets state setting.
Parameters
GetResponseEvent $event:
File
- src/
EventSubscriber/ EloquaEventSubscriber.php, line 72 - Contains Drupal\eloqua\EventSubscriber\EloquaEventSubscriber
Class
- EloquaEventSubscriber
- Provides a response event subscriber for Eloqua. Sets config value for use in eloqua.module.
Namespace
Drupal\eloqua\EventSubscriberCode
public function evaluateTrackingScope(GetResponseEvent $event) {
if (null !== $this->config
->get('site_identifier')) {
$user_role_config = $this->config
->get('user_roles');
$current_user = $this->userStorage
->load($this->account
->id());
/* @var \Drupal\user\Plugin\Condition\UserRole $condition */
$user_role = $this->conditionManager
->createInstance('user_role')
->setConfig('roles', $user_role_config['roles'])
->setContextValue('user', $current_user);
$user_role_result = $user_role
->evaluate();
/* @var \Drupal\system\Plugin\Condition\RequestPath $request_path */
$request_path = $this->conditionManager
->createInstance('request_path');
$request_path
->setConfiguration($this->config
->get('request_path'));
// Negate request_path if applicable.
$request_path_result = $request_path
->isNegated() ? !$request_path
->evaluate() : $request_path
->evaluate();
if ($user_role_result && $request_path_result) {
\Drupal::state()
->set('eloqua.condition_result', 1);
}
else {
\Drupal::state()
->set('eloqua.condition_result', 0);
}
}
}