sanitizeValue example

parent::buildOptionsForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);
    if (!empty($this->options['display_as_link'])) {
      // @todo Views should expect and store a leading /. See:       // https://www.drupal.org/node/2423913       return Link::fromTextAndUrl($this->sanitizeValue($value), CoreUrl::fromUserInput('/' . $value))->toString();
    }
    else {
      return $this->sanitizeValue($value, 'url');
    }
  }

}
/** * {@inheritdoc} */
  public function preRender(&$values) {}

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);
    return $this->sanitizeValue($value);
  }

  /** * {@inheritdoc} */
  public function postRender(ResultRow $row$output) {
    // Make sure the last rendered value is available also when this is     // retrieved from cache.     $this->last_render = $output;
    return [];
  }

  
/** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);

    if ($this->options['replace_variables']) {
      $variables = unserialize($this->getvalue($values, 'variables'));
      return new FormattableMarkup($value(array) $variables);
    }
    else {
      return $this->sanitizeValue($value);
    }
  }

}

    }

    return [];
  }

  /** * Render a text area with \Drupal\Component\Utility\Xss::filterAdmin(). */
  public function renderTextarea($value) {
    if ($value) {
      return $this->sanitizeValue($this->tokenizeValue($value), 'xss_admin');
    }
  }

}
$name$value] = explode('=', $name, 2);
        }

        $name  = trim($name);
        $value = trim($value);

        // Sanitize the name         $name = preg_replace('/^export[ \t]++(\S+)/', '$1', $name);
        $name = str_replace(['\'', '"'], '', $name);

        // Sanitize the value         $value = $this->sanitizeValue($value);
        $value = $this->resolveNestedVariables($value);

        return [$name$value];
    }

    /** * Strips quotes from the environment variable value. * * This was borrowed from the excellent phpdotenv with very few changes. * https://github.com/vlucas/phpdotenv * * @throws InvalidArgumentException */
/** * {@inheritdoc} */
  protected function addSelfTokens(&$tokens$item) {
    $tokens['{{ test_token }}'] = $this->getTestValue();
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    return $this->sanitizeValue($this->getTestValue());
  }

  /** * A mock function which allows to call placeholder from public. * * @return string * The result of the placeholder method. */
  public function getPlaceholder() {
    return $this->placeholder();
  }

}
return '';
    }

    $value = number_format($value$precision$this->options['decimal']$this->options['separator']);

    // If we should format as plural, take the (possibly) translated plural     // setting and format with the current language.     if (!empty($this->options['format_plural'])) {
      $value = PluralTranslatableMarkup::createFromTranslatedString($value$this->options['format_plural_string']);
    }

    return $this->sanitizeValue($this->options['prefix'], 'xss')
      . $this->sanitizeValue($value)
      . $this->sanitizeValue($this->options['suffix'], 'xss');
  }

}
$this->options['alter']['url'] = $this->fileUrlGenerator->generate($this->getValue($values, 'uri'));
    }

    return $data;
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);
    return $this->renderLink($this->sanitizeValue($value)$values);
  }

}
$form_state->setError($form['key']$this->t('You have to enter a key if you want to display a key of the data.'));
    }
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $values->{$this->field_alias};

    if ($this->options['format'] == 'unserialized') {
      return $this->sanitizeValue(print_r(unserialize($value), TRUE));
    }
    elseif ($this->options['format'] == 'key' && !empty($this->options['key'])) {
      $value = (array) unserialize($value);
      return $this->sanitizeValue($value[$this->options['key']]);
    }

    return $value;
  }

}

  protected function renderLink(ResultRow $row) {
    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['url'] = $this->getUrlInfo($row);
    $text = !empty($this->options['text']) ? $this->sanitizeValue($this->options['text']) : $this->getDefaultLabel();
    $this->addLangcode($row);
    return $text;
  }

  /** * Adds language information to the options. * * @param \Drupal\views\ResultRow $row * A view result row. */
  protected function addLangcode(ResultRow $row) {
    

  public function clickSortable() {
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);
    return $this->sanitizeValue($value, 'xss_admin');
  }

}
$this->options['alter']['make_link'] = FALSE;
      }
    }
    return $data;
  }

  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $value = $this->getValue($values);
    return $this->renderLink($this->sanitizeValue($value)$values);
  }

}
$this->options['alter']['url'] = $entity->toUrl();
        $this->options['alter']['make_link'] = TRUE;
      }
      catch (UndefinedLinkTemplateException $e) {
        $this->options['alter']['make_link'] = FALSE;
      }
      catch (EntityMalformedException $e) {
        $this->options['alter']['make_link'] = FALSE;
      }
    }

    return $this->sanitizeValue($entity->label());
  }

  /** * {@inheritdoc} */
  public function preRender(&$values) {
    parent::preRender($values);

    $entity_ids_per_type = [];
    foreach ($values as $value) {
      if ($type = $this->getValue($value, 'type')) {
        
if (!empty($this->options['link_to_user'])) {
      $account = User::create();
      $account->name = $this->getValue($values);
      $account->uid = $values->{$this->uid};
      $username = [
        '#theme' => 'username',
        '#account' => $account,
      ];
      return \Drupal::service('renderer')->render($username);
    }
    else {
      return $this->sanitizeValue($this->getValue($values));
    }
  }

}


  /** * {@inheritdoc} */
  public function render(ResultRow $values) {
    $uid = $this->getValue($values);
    $data = $this->userData->get($this->options['data_module']$uid$this->options['data_name']);

    // Don't sanitize if no value was found.     if (isset($data)) {
      return $this->sanitizeValue($data);
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.