- Issue created by @sidney.desousa
- πΊπΈUnited States DamienMcKenna NH, USA
It sounds like uou'll need to extend MetaNameBase::form(), MetaNameBase::value() and MetaNameBase::setValue(), possibly some others too. If you want to have test coverage you'll also need to extend MetaNameBase::getTestFormXpath(), MetaNameBase::getTestFormData(), MetaNameBase::getTestOutputExistsXpath() and MetaNameBase::getTestOutputValuesXpath().
#2 after digging a bit into other implementations I see a light at the end of the tunnel.
My class looks like this
<?php namespace Drupal\metatag_csp\Plugin\metatag\Tag; use Drupal\Core\Form\FormStateInterface; use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase; use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Provides the Content Security Policy (CSP) meta tag. * * @MetatagTag( * id = "csp", * label = @Translation("Content Security Policy"), * description = @Translation("Specifies the Content Security Policy directives for this page."), * name = "csp", * group = "advanced", * weight = 10, * type = "http-equiv", * secure = TRUE, * multiple = FALSE * ) */ class ContentSecurityPolicy extends MetaNameBase { use StringTranslationTrait; /** * {@inheritdoc} */ public function form(array $element = []): array { $form = []; $form['csp_default_src'] = [ '#type' => 'details', '#title' => $this->t('default-src Directive'), '#open' => TRUE, ]; $form['csp_default_src']['default-src'] = [ '#type' => 'radios', '#default_value' => "", '#options' => [ 'self' => $this->t('Self'), 'none' => $this->t('None'), 'any' => $this->t('Any'), 'n/a' => $this->t('n/a') ], ]; $form['csp_default_src']['additional_resources'] = [ '#type' => 'textarea', '#title' => $this->t('Additional Resources'), '#default_value' => "", '#description' => $this->t('Specify additional resources for default-src.'), ]; return $form; } }
When I go to a page and save my changes, I notice that the values are not saving and I am struggling to understand how this config can be saved and retrieved if exists.