You are here

public function PackageWeight::render in Ubercart 8.4

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides Weight::render

File

shipping/uc_fulfillment/src/Plugin/views/field/PackageWeight.php, line 40

Class

PackageWeight
Field handler to provide the weight of the package.

Namespace

Drupal\uc_fulfillment\Plugin\views\field

Code

public function render(ResultRow $values) {
  $package = Package::load($values->{$this->aliases['package_id']});
  if ($this->options['format'] == 'numeric') {
    return $package
      ->getWeight();
  }
  if ($this->options['format'] == 'uc_weight') {
    return uc_weight_format($package
      ->getWeight(), $package
      ->getWeightUnits());
  }
}