-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to filter out visits from staff
- Loading branch information
Showing
7 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Schema for the configuration files of the Entity Metrics module. | ||
entity_metrics.settings: | ||
type: config_object | ||
label: 'Entity Metrics settings' | ||
mapping: | ||
cookie: | ||
type: string | ||
label: 'Cookie' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
entity_metrics.settings: | ||
title: Entity Metrics | ||
description: Configure the entity metrics module | ||
parent: system.admin_config_system | ||
route_name: entity_metrics.settings | ||
weight: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\entity_metrics\Form; | ||
|
||
use Drupal\Core\Form\ConfigFormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Configure Entity Metrics settings for this site. | ||
*/ | ||
final class SettingsForm extends ConfigFormBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId(): string { | ||
return 'entity_metrics_settings'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getEditableConfigNames(): array { | ||
return ['entity_metrics.settings']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state): array { | ||
$form['cookie'] = [ | ||
'#type' => 'textfield', | ||
'#title' => $this->t('Cookie name'), | ||
'#description' => $this->t('<p>Name of cookie that when set and equal to "1" will set a flag to allow filtering out those metrics.</p> | ||
<p>This allows not tracking things like staff page views.</p> | ||
<p>The value will need set by some other service, this module does not handle setting the cookie. e.g. <a href="https://github.com/lehigh-university-libraries/cookie-toggler">cookie-toggler</a>.</p>'), | ||
'#default_value' => $this->config('entity_metrics.settings')->get('cookie'), | ||
]; | ||
return parent::buildForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state): void { | ||
$this->config('entity_metrics.settings') | ||
->set('cookie', $form_state->getValue('cookie')) | ||
->save(); | ||
parent::submitForm($form, $form_state); | ||
} | ||
|
||
} |