getAdminTagList example

foreach ($options[$type] as $key => $value) {
            $items[] = $key . ' == ' . $value;
          }
          $form['tokens'][$type]['tokens'] = [
            '#theme' => 'item_list',
            '#items' => $items,
          ];
        }
      }
      $form['tokens']['html_help'] = [
        '#markup' => '<p>' . $this->t('You may include the following allowed HTML tags with these "Replacement patterns": <code>@tags</code>', [
          '@tags' => '<' . implode('> <', Xss::getAdminTagList()) . '>',
        ]) . '</p>',
      ];
    }

    $this->globalTokenForm($form$form_state);
  }

  /** * Replaces value with special views tokens and global tokens. * * @param string $value * The value to eventually tokenize. * * @return string * Tokenized value if tokenize option is enabled. In any case global tokens * will be replaced. */
'#title' => $this->t('Override the output of this field with custom text'),
        '#default_value' => $this->options['alter']['alter_text'],
      ];

      $form['alter']['text'] = [
        '#title' => $this->t('Text'),
        '#type' => 'textarea',
        '#default_value' => $this->options['alter']['text'],
        // The tag list will be escaped.         '#description' => $this->t('The text to display for this field. You may enter data from this view as per the "Replacement patterns" below. You may include <a href="@twig_docs">Twig</a> or the following allowed HTML tags: <code>@tags</code>', [
          '@twig_docs' => 'https://twig.symfony.com/doc/' . Environment::MAJOR_VERSION . '.x',
          '@tags' => '<' . implode('> <', Xss::getAdminTagList()) . '>',
        ]),
        '#states' => [
          'visible' => [
            ':input[name="options[alter][alter_text]"]' => ['checked' => TRUE],
          ],
        ],
      ];

      $form['alter']['make_link'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Output this field as a custom link'),
        

  protected function stripAdminAndAnchorTagsFromResults(array $results) {
    $allowed_tags = Xss::getAdminTagList();
    if (($key = array_search('a', $allowed_tags)) !== FALSE) {
      unset($allowed_tags[$key]);
    }

    $stripped_results = [];
    foreach (Element::children($results) as $id) {
      $entity = $results[$id]['#row']->_entity;
      $stripped_results[$entity->bundle()][$id] = ViewsRenderPipelineMarkup::create(
        Xss::filter($this->renderer->renderPlain($results[$id])$allowed_tags)
      );
    }

    
/** * {@inheritdoc} */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);

    $form['content'] = [
      '#title' => $this->t('Content'),
      '#type' => 'textarea',
      '#description' => $this->t('You may enter data from this view as per the "Available global token replacements" above. You may include the following allowed HTML tags: <code>@tags</code>', [
        '@tags' => '<' . implode('> <', Xss::getAdminTagList()) . '>',
      ]),
      '#default_value' => $this->options['content'],
      '#rows' => 6,
    ];
  }

  /** * {@inheritdoc} */
  public function render($empty = FALSE) {
    if (!$empty || !empty($this->options['empty'])) {
      

  protected function ensureMarkupIsSafe(array $elements) {
    if (isset($elements['#plain_text'])) {
      $elements['#markup'] = Markup::create(Html::escape($elements['#plain_text']));
    }
    elseif (!($elements['#markup'] instanceof MarkupInterface)) {
      // The default behavior is to XSS filter using the admin tag list.       $tags = $elements['#allowed_tags'] ?? Xss::getAdminTagList();
      $elements['#markup'] = Markup::create(Xss::filter($elements['#markup']$tags));
    }

    return $elements;
  }

  /** * Performs a callback. * * @param string $callback_type * The type of the callback. For example, '#post_render'. * @param string|callable $callback * The callback to perform. * @param array $args * The arguments to pass to the callback. * * @return mixed * The callback's return value. * * @see \Drupal\Core\Security\TrustedCallbackInterface */
Home | Imprint | This part of the site doesn't use cookies.