interface SafeStringInterface in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/Component/Utility/SafeStringInterface.php \Drupal\Component\Utility\SafeStringInterface
Marks an object's __toString() method as returning safe markup.
All objects that implement this interface should be marked @internal.
This interface should only be used on objects that emit known safe strings from their __toString() method. If there is any risk of the method returning user-entered data that has not been filtered first, it must not be used.
If the object is going to be used directly in Twig templates it should implement \Countable so it can be used in if statements.
@internal This interface is marked as internal because it should only be used by objects used during rendering. This interface should be used by modules if they interrupt the render pipeline and explicitly deal with SafeString objects created by the render system. Additionally, if a module reuses the regular render pipeline internally and passes processed data into it. For example, Views implements a custom render pipeline in order to render JSON and to fast render fields.
Hierarchy
- interface \Drupal\Component\Utility\SafeStringInterface
Expanded class hierarchy of SafeStringInterface
All classes that implement SafeStringInterface
See also
\Drupal\Component\Utility\SafeStringTrait
\Drupal\Component\Utility\SafeMarkup::set()
\Drupal\Component\Utility\SafeMarkup::isSafe()
\Drupal\Core\Template\TwigExtension::escapeFilter()
File
- lib/
Drupal/ Component/ Utility/ SafeStringInterface.php, line 36 - Contains \Drupal\Component\Utility\SafeStringInterface.
Namespace
Drupal\Component\UtilityView source
interface SafeStringInterface {
/**
* Returns a safe string.
*
* @return string
* The safe string.
*/
public function __toString();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SafeStringInterface:: |
public | function | Returns a safe string. |