UnitService

This service class contains functions related to units.
All public functions are available in the Twig template renderer.

Deprecated!

since 5.0.0 will be removed in 6.0.0

Namespace

IO\Services

Constants
Type Name Value Description

int

METER

1

int

DECIMETER

2

int

CENTIMETER

3

int

MILLIMETER

4

Properties
Type Name Description

UnitNameRepositoryContract

$unitNameRepository

UnitRepositoryContract

$unitRepository

array

$aMeasureUnits

``

$cache

Methods
public __construct($unitNameRepository, $unitRepository)

UnitService constructor.

Parameters

Type

Name

Description

UnitNameRepositoryContract

$unitNameRepository

UnitRepositoryContract

$unitRepository

public getUnitById($unitId, $lang = "de"):UnitName
Deprecated!

since 5.0.0 will be removed in 6.0.0

Get the unit by id

Parameters

Type

Name

Description

int

$unitId

An unit id

string

$lang

Optional: Language to get unit for (ISO-639-1) (Default: 'de')

public getUnitNameByKey($unitKey, $lang = null):mixed
Deprecated!

since 5.0.0 will be removed in 6.0.0

Get the name of an unit by it's unit key

Parameters

Type

Name

Description

string

$unitKey

A unit key

string

$lang

Optional: Language of the name (ISO-639-1) (Default: The current language)

public static isValidUnit($sUnit):bool
Deprecated!

since 5.0.0 will be removed in 6.0.0

Checks if the given string unit is a valid one for the PlentyDimension.

Parameters

Type

Name

Description

string

$sUnit

The unit to be checked

public static getHTML4Unit($sUnit = "SMM"):string
Deprecated!

since 5.0.0 will be removed in 6.0.0

Returns HTML code for the unit ('m','cm' o'MM')

Parameters

Type

Name

Description

string

$sUnit

One of 'MTK', 'SCM', 'SMM'

public fromMemoryCache()
public resetMemoryCache($key = null)
Parameters

Type

Name

Description

``

$key