interface MarkupInterface
Same name in other branches
- 9 core/lib/Drupal/Component/Render/MarkupInterface.php \Drupal\Component\Render\MarkupInterface
- 8.9.x core/lib/Drupal/Component/Render/MarkupInterface.php \Drupal\Component\Render\MarkupInterface
- 11.x 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 \Drupal\Component\Render\Stringable
Expanded class hierarchy of MarkupInterface
All classes that implement MarkupInterface
See also
\Drupal\Component\Render\MarkupTrait
\Drupal\Core\Template\TwigExtension::escapeFilter()
\Drupal\Component\Render\FormattableMarkup
\Drupal\Core\StringTranslation\TranslatableMarkup
\Drupal\views\Render\ViewsRenderPipelineMarkup
sanitization
43 files declare their use of MarkupInterface
- Attribute.php in core/
lib/ Drupal/ Core/ Template/ Attribute.php - AttributeTest.php in core/
tests/ Drupal/ Tests/ Core/ Template/ AttributeTest.php - AuditResult.php in core/
modules/ migrate/ src/ Audit/ AuditResult.php - BigPipeMarkup.php in core/
modules/ big_pipe/ src/ Render/ BigPipeMarkup.php - CommentPreviewTest.php in core/
modules/ comment/ tests/ src/ Functional/ CommentPreviewTest.php
File
-
core/
lib/ Drupal/ Component/ Render/ MarkupInterface.php, line 32
Namespace
Drupal\Component\RenderView source
interface MarkupInterface extends \JsonSerializable, \Stringable {
/**
* Returns markup.
*
* @return string
* The markup.
*/
public function __toString();
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
MarkupInterface::__toString | public | function | Returns markup. | 5 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.