You are here

protected function BarcodeFormatterBase::generateBarcode in Barcode 8

Generate the barcode object.

Parameters

Drupal\barcode\Plugin\Field\FieldType\BarcodeBase $field: The field.

str $background: The background color.

str $foreground: The foreground color.

Return value

Com\Tecnick\Barcode\Type The barcode object.

3 calls to BarcodeFormatterBase::generateBarcode()
BarcodeFormatterHtml::viewElements in src/Plugin/Field/FieldFormatter/BarcodeFormatterHtml.php
Builds a renderable array for a field value.
BarcodeFormatterPng::viewElements in src/Plugin/Field/FieldFormatter/BarcodeFormatterPng.php
Builds a renderable array for a field value.
BarcodeFormatterSvg::viewElements in src/Plugin/Field/FieldFormatter/BarcodeFormatterSvg.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/BarcodeFormatterBase.php, line 82

Class

BarcodeFormatterBase
Base for barcode formatters.

Namespace

Drupal\barcode\Plugin\Field\FieldFormatter

Code

protected function generateBarcode(BarcodeBase $field, $background, $foreground) {
  $barcode_generator = new Barcode();
  return $barcode_generator
    ->getBarcodeObj($field->type, $field->value, -2, -50, $foreground, [
    10,
    10,
    10,
    10,
  ])
    ->setBackgroundColor($background);

  // background color
}