class AmpAnalyticsService in Analytics 7
Hierarchy
- class \AnalyticsService implements AnalyticsServiceInterface
- class \AmpAnalyticsService
Expanded class hierarchy of AmpAnalyticsService
1 string reference to 'AmpAnalyticsService'
- analytics_amp_analytics_service_info in analytics_amp/
analytics_amp.module - Implements hook_analytics_service_info().
File
- analytics_amp/
src/ AmpAnalyticsService.php, line 3
View source
class AmpAnalyticsService extends AnalyticsService {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return array(
'type' => NULL,
'config_url' => '',
'config_json' => array(),
'data-credentials' => 0,
'data-consent-notification-id' => '',
);
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm($form, &$form_state) {
$options['type'] = array(
'#title' => t('Type'),
'#type' => 'select',
'#default_value' => $this
->getConfiguration()['type'],
'#options' => array(
// @todo Add support for all options.
'adobeanalytics' => t('Adobe Analytics'),
'googleanalytics' => t('Google Analytics'),
),
'#required' => TRUE,
);
$options['config_url'] = array(
'#title' => t('Remote configuration JSON URL'),
'#type' => 'urlfield',
'#default_value' => $this
->getConfiguration()['config_url'],
'#placeholder' => 'https://example.com/analytics.config.json',
'#element_validate' => array(
'analytics_amp_element_validate_config_url',
),
);
$options['config_json'] = array(
'#title' => t('Inline configuration JSON'),
'#type' => 'textarea',
'#default_value' => json_encode($this
->getConfiguration()['config_json'], JSON_PRETTY_PRINT | JSON_FORCE_OBJECT),
'#element_validate' => array(
'analytics_amp_element_validate_config_json',
),
);
return $options;
}
/**
* {@inheritdoc}
*/
public function getOutput(array $context) {
if (amp_is_amp_request()) {
return $this
->getAmpOutput($this
->getConfiguration(), $context);
}
}
}