class CrazyeggSettingsForm in Crazy Egg Integration 8
Returns responses for Crazyegg module routes.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\crazyegg\Form\CrazyeggSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of CrazyeggSettingsForm
1 string reference to 'CrazyeggSettingsForm'
File
- src/
Form/ CrazyeggSettingsForm.php, line 18 - Contains Drupal\crazyegg\Form\CrazyeggSettingsForm.
Namespace
Drupal\crazyegg\FormView source
class CrazyeggSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'crazyegg_settings_form';
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('crazyegg.settings')
->set('crazyegg_enabled', $form_state
->getValue('crazyegg_enabled'))
->set('crazyegg_account_id', $form_state
->getValue('crazyegg_account_id'))
->set('crazyegg_js_scope', $form_state
->getValue('crazyegg_js_scope'))
->set('crazyegg_roles_excluded', $form_state
->getValue('crazyegg_roles_excluded'))
->set('crazyegg_paths', $form_state
->getValue('crazyegg_paths'))
->save();
if (method_exists($this, '_submitForm')) {
$this
->_submitForm($form, $form_state);
}
parent::submitForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'crazyegg.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
$form = [];
$form['crazyegg_heading'] = array(
'#type' => 'item',
'#markup' => $this
->t('<img src="@logo" style="float: right;" alt="Crazy Egg">' . '<a href="@url">Crazy Egg</a> is an analytics tool that provides website heatmaps and eye tracking.<br/><br/>', array(
'@url' => 'https://www.crazyegg.com',
'@logo' => 'https://ceblog.s3.amazonaws.com/wp-content/uploads/2015/06/Crazy-Egg-logo-small.png',
)),
);
$form['crazyegg_enabled'] = array(
'#type' => 'radios',
'#title' => $this
->t('Crazy Egg Enabled?'),
'#default_value' => \Drupal::config('crazyegg.settings')
->get('crazyegg_enabled'),
'#options' => array(
1 => $this
->t('Yes'),
-1 => $this
->t('No'),
),
);
$form['crazyegg_account_id'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Crazy Egg Account ID'),
'#attributes' => array(
'placeholder' => $this
->t('e.g. 00111111'),
),
'#default_value' => \Drupal::config('crazyegg.settings')
->get('crazyegg_account_id'),
'#description' => $this
->t('This is your numerical CrazyEgg account ID, it is 8 digits long.<br/>' . 'The easiest way to find it is by logging in to your CrazyEgg account.<br/>' . 'Click on Account. Under your profile and email address, you’ll see your account number.'),
);
$form['advanced_settings'] = array(
'#type' => 'details',
'#title' => $this
->t('More settings'),
'#open' => FALSE,
);
$form['advanced_settings']['crazyegg_js_scope'] = array(
'#type' => 'radios',
'#title' => $this
->t('Location to add the tracking script'),
'#description' => $this
->t('Controls where on the page the tracking script is added'),
'#default_value' => \Drupal::config('crazyegg.settings')
->get('crazyegg_js_scope'),
'#options' => array(
'header' => $this
->t('Header <em>(recommended)</em>'),
'footer' => $this
->t('Footer'),
),
);
$form['advanced_settings']['crazyegg_roles_excluded'] = array(
'#type' => 'checkboxes',
'#options' => user_role_names(),
'#title' => $this
->t('Excluded roles (optional)'),
'#default_value' => \Drupal::config('crazyegg.settings')
->get('crazyegg_roles_excluded'),
'#description' => $this
->t('You can control which visits and clicks are tracked in Crazy Egg by excluding roles.<br/>' . 'For example, if you have traffic generated by employees, it’s difficult to distinguish visits ' . 'from your visitors versus those visits from your own employees.<br/>' . 'To prevent internal traffic (i.e. administrators) from diluting your data, select "Administrator."'),
);
$form['advanced_settings']['crazyegg_paths'] = array(
'#type' => 'textarea',
'#title' => $this
->t('Pages to track (optional)'),
'#default_value' => \Drupal::config('crazyegg.settings')
->get('crazyegg_paths'),
'#description' => $this
->t('By default, Crazy Egg will track all pages within your domain.<br/>' . 'Need to track specific pages instead of all pages? You can specify which pages you\'d like to track ' . 'by providing the path (everything after .com). Include one path per line. For example,' . '<pre> /home/about<br/> /posts<br/> /posts/*<br/> /users/*/details</pre>'),
'#cols' => 100,
'#rows' => 5,
'#resizable' => FALSE,
'#required' => FALSE,
'#weight' => 40,
);
$form['crazyegg_help'] = array(
'#type' => 'item',
'#markup' => $this
->t('<em>Note: if you don\'t get the desired effect after changing some settings, try clearing Drupal cache.</em><br/><br/>' . '<strong>Support:</strong> <a href="mailto:support@crazyegg.com">support@crazyegg.com</a><br />' . '<strong>Website: </strong><a href="https://www.crazyegg.com" target="_blank">https://www.crazyegg.com</a>'),
);
return parent::buildForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
CrazyeggSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
CrazyeggSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
CrazyeggSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
CrazyeggSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |