You are here

class CSSSnippet in Background Image Field 8

This class will clean up the css string we have created in the formatter.

Hierarchy

Expanded class hierarchy of CSSSnippet

1 file declares its use of CSSSnippet
BgImgFieldFormatter.php in src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php

File

src/Component/Render/CSSSnippet.php, line 10

Namespace

Drupal\bg_img_field\Component\Render
View source
class CSSSnippet implements MarkupInterface {

  /**
   * The string to escape.
   *
   * @var string
   */
  protected $string;

  /**
   * Constructs an HtmlEscapedText object.
   *
   * @param string $string
   *   The string to escape. This value will be cast to a string.
   */
  public function __construct($string) {
    $this->string = (string) $string;
  }

  /**
   * {@inheritdoc}
   */
  public function __toString() {
    return $this->string;
  }

  /**
   * {@inheritdoc}
   */
  public function jsonSerialize() {
    return $this
      ->__toString();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CSSSnippet::$string protected property The string to escape.
CSSSnippet::jsonSerialize public function
CSSSnippet::__construct public function Constructs an HtmlEscapedText object.
CSSSnippet::__toString public function Returns markup. Overrides MarkupInterface::__toString