CoolCMS API

Unit extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait, TranslationCollectionTrait

AbstractYes

Unit of measure (`cms_system_units`): piece, kilogram, meter…

Lives in the System module, not in the e-shop: units are not an e-shop property, they suit warehouse, invoicing and adverts too.

NOTE: a product (ProductSet::$unit) does not reference this code list yet and keeps the unit as free text. The bridge for future pairing is code, which is unique and matches the values actually used in products.

Tags
template
Attributes
#[MappedSuperclass]
#[TableAlias]
$alias: 'unit'

Table of Contents

Interfaces

IdentifiableInterface
Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).

Properties

$active  : bool
$code  : string
$id  : int|null
$sort  : int
$translations  : Collection<int, TTranslation>

Methods

__construct()  : mixed
addTranslation()  : $this
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getActive()  : bool
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getCode()  : string
getId()  : int|null
getSort()  : int
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
isActive()  : bool
isPersisted()  : bool
removeTranslation()  : $this
setActive()  : TTranslation>
setCode()  : TTranslation>
setId()  : $this
setSort()  : TTranslation>
setTranslations()  : $this
translationCollectionInit()  : void
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$active

protected bool $active = true
Attributes
#[Column]
$name: 'active'
$type: 'boolean'

$code

protected string $code = ''
Attributes
#[Column]
$name: 'code'
$type: 'string'
$length: 20

$id

protected int|null $id = null
Attributes
#[Column]
$name: 'unit_id'
$type: 'integer'
$options: ['unsigned' => true]
#[GeneratedValue]
#[Id]

$sort

protected int $sort = 0
Attributes
#[Column]
$name: 'sort'
$type: 'integer'

$translations

protected Collection<int, TTranslation> $translations = new ArrayCollection()

Methods

__construct()

public __construct([int|null $id = null ][, string $code = '' ][, int $sort = 0 ][, bool $active = true ][, Collection $translations = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$code : string = ''
$sort : int = 0
$active : bool = true
$translations : Collection = new ArrayCollection()

addTranslation()

public addTranslation(TTranslation $translation) : $this
Parameters
$translation : TTranslation
Return values
$this

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getActive()

public getActive() : bool
Return values
bool

getAllTraits()

Returns all traits the class uses, including those used by parent classes and nested traits.

public getAllTraits() : array<string, string>
Return values
array<string, string>

getCode()

public getCode() : string
Return values
string

getSort()

public getSort() : int
Return values
int

getTranslation()

public getTranslation(int $langId) : TTranslation|null
Parameters
$langId : int
Return values
TTranslation|null

getTranslations()

public getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>

isActive()

public isActive() : bool
Return values
bool

removeTranslation()

public removeTranslation(TTranslation $translation) : $this
Parameters
$translation : TTranslation
Return values
$this

setActive()

public setActive(bool $active) : TTranslation>
Parameters
$active : bool
Return values
TTranslation>

setCode()

public setCode(string $code) : TTranslation>
Parameters
$code : string
Return values
TTranslation>

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

setSort()

public setSort(int $sort) : TTranslation>
Parameters
$sort : int
Return values
TTranslation>

setTranslations()

public setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
$translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$this

getTraitsRecursive()

Walks the trait list recursively and collects nested traits too.

private static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
$traits : array<string, string>
Return values
array<string, string>
On this page

Search results