You are here

class UnitsMathematicalExpressionWrapper in Units of Measurement 7.2

Wrapper around "mathematical expression" objects for ease of db storage.

Hierarchy

Expanded class hierarchy of UnitsMathematicalExpressionWrapper

File

./units.module, line 1916
Provide API for managing and converting units of measurement.

View source
class UnitsMathematicalExpressionWrapper {

  /**
   * Mathematical expression ID of this mathematical expression, if known.
   *
   * @var int
   */
  protected $mathematical_expression_id;

  /**
   * Pointer to the underlying mathematical expression object.
   *
   * @var UnitsMathematicalExpression
   */
  protected $expression;

  /**
   * Get underlying mathematical expression.
   *
   * @return \UnitsMathematicalExpression
   *   The underlying mathematical expression
   */
  public function getExpression() {
    return $this->expression;
  }

  /**
   * Set underlying mathematical expression.
   *
   * @param \UnitsMathematicalExpression $expression
   *   Mathematical expression to set as underlying one
   */
  public function setExpression(UnitsMathematicalExpression $expression) {
    $this->expression = $expression;
  }

  /**
   * Save the underlying mathematical expression into database.
   */
  public function save() {
    if ($this
      ->getMathematicalExpressionId()) {
      units_mathematical_expression_delete($this
        ->getMathematicalExpressionId());
    }
    $order = 0;
    $this
      ->setMathematicalExpressionId($this
      ->getExpression()
      ->unitsMathematicalExpressionSave($this
      ->getMathematicalExpressionId(), $order));
  }

  /**
   * Get mathematical expression ID of this mathematical expression.
   *
   * @return int
   *   Mathematical expression ID of this mathematical expression
   */
  public function getMathematicalExpressionId() {
    return $this->mathematical_expression_id;
  }

  /**
   * Set mathematical expression ID of this mathematical expression.
   *
   * When saving this mathematical expression into database the old entries of
   * this mathematical expression ID will be removed prior saving the in-memory
   * representation.
   *
   * @param int $mathematical_expression_id
   *   Mathematical expression ID of this mathematical expression
   */
  public function setMathematicalExpressionId($mathematical_expression_id) {
    $this->mathematical_expression_id = $mathematical_expression_id;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UnitsMathematicalExpressionWrapper::$expression protected property Pointer to the underlying mathematical expression object.
UnitsMathematicalExpressionWrapper::$mathematical_expression_id protected property Mathematical expression ID of this mathematical expression, if known.
UnitsMathematicalExpressionWrapper::getExpression public function Get underlying mathematical expression.
UnitsMathematicalExpressionWrapper::getMathematicalExpressionId public function Get mathematical expression ID of this mathematical expression.
UnitsMathematicalExpressionWrapper::save public function Save the underlying mathematical expression into database.
UnitsMathematicalExpressionWrapper::setExpression public function Set underlying mathematical expression.
UnitsMathematicalExpressionWrapper::setMathematicalExpressionId public function Set mathematical expression ID of this mathematical expression.