You are here

interface MarkupInterface in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Render/MarkupInterface.php \Drupal\Component\Render\MarkupInterface

Marks an object's __toString() method as returning markup.

Objects that implement this interface will not be automatically XSS filtered by the render system or automatically escaped by the theme engine.

If there is any risk of the object's __toString() method returning user-entered data that has not been filtered first, it must not be used. If the object that implements this does not perform automatic escaping or filtering itself, then it must be marked as "@internal". For example, Views has the internal ViewsRenderPipelineMarkup object to provide a custom render pipeline in order to render JSON and to fast render fields. By contrast, FormattableMarkup and TranslatableMarkup always sanitize their output when used correctly.

If the object is going to be used directly in Twig templates it should implement \Countable so it can be used in if statements.

Hierarchy

  • interface \Drupal\Component\Render\MarkupInterface extends \Drupal\Component\Render\JsonSerializable

Expanded class hierarchy of MarkupInterface

All classes that implement MarkupInterface

See also

\Drupal\Component\Render\MarkupTrait

\Drupal\Component\Utility\SafeMarkup::isSafe()

\Drupal\Core\Template\TwigExtension::escapeFilter()

\Drupal\Component\Render\FormattableMarkup

\Drupal\Core\StringTranslation\TranslatableMarkup

\Drupal\views\Render\ViewsRenderPipelineMarkup

twig_render_template()

Sanitization functions

Render API overview

28 files declare their use of MarkupInterface
AssertHelperTrait.php in core/modules/simpletest/src/AssertHelperTrait.php
Contains \Drupal\simpletest\AssertHelperTrait.
Attribute.php in core/lib/Drupal/Core/Template/Attribute.php
Contains \Drupal\Core\Template\Attribute.
AttributeTest.php in core/tests/Drupal/Tests/Core/Template/AttributeTest.php
Contains \Drupal\Tests\Core\Template\AttributeTest.
ConfigBase.php in core/lib/Drupal/Core/Config/ConfigBase.php
Contains \Drupal\Core\Config\ConfigBase.
DrupalTranslator.php in core/lib/Drupal/Core/Validation/DrupalTranslator.php
Contains \Drupal\Core\Validation\DrupalTranslator.

... See full list

File

core/lib/Drupal/Component/Render/MarkupInterface.php, line 38
Contains \Drupal\Component\Render\MarkupInterface.

Namespace

Drupal\Component\Render
View source
interface MarkupInterface extends \JsonSerializable {

  /**
   * Returns markup.
   *
   * @return string
   *   The markup.
   */
  public function __toString();

}

Members