You are here

class Color in Color Field 8

Hierarchy

  • class \Drupal\color_field\Color

Expanded class hierarchy of Color

2 string references to 'Color'
ColorFieldDefaultWidget::formElement in src/Plugin/Field/FieldWidget/ColorFieldDefaultWidget.php
Returns the form for a single field widget.
ColorFieldItem::propertyDefinitions in src/Plugin/Field/FieldType/ColorFieldItem.php
Defines field item properties.

File

src/Color.php, line 10
Contains Drupal\color_field\Color.

Namespace

Drupal\color_field
View source
class Color {

  /**
   * The color.
   *
   * @var string
   */
  protected $color;

  /**
   * The opacity.
   *
   * @var float
   */
  protected $opacity;

  /**
   * Creates a Color instance.
   *
   * @param string $color The color.
   * @param float $opacity The opacity.
   */
  public function __construct($color, $opacity) {
    $this->color = $color;
    $this->opacity = $opacity;
  }

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

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

  /**
   * Returns the string representation of the color (color, opacity).
   *
   * @return string
   */
  public function __toString() {
    return $this->color . ' ' . $this->opacity;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Color::$color protected property The color.
Color::$opacity protected property The opacity.
Color::getColor public function
Color::getOpacity public function
Color::__construct public function Creates a Color instance.
Color::__toString public function Returns the string representation of the color (color, opacity).