Unit
extends Unit
in package
Admin variant of a unit of measure (`cms_system_units`), hydrated from the Api endpoint `api/system/unit`; maps translations (full name).
Tags
Attributes
- #[Entity]
- #[Table]
- $name: 'cms_system_units'
- #[TableAlias]
- 'unit'
Table of Contents
Properties
- $active : bool
- $code : string
- $id : int|null
- $sort : int
- $translations : Collection
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
$translations
Attributes
- #[CollectionOf]
- \App\UI\Admin\System\Models\Entities\UnitText::class
- $owned: true
- #[OneToMany]
- $targetEntity: \App\UI\Admin\System\Models\Entities\UnitText::class
- $mappedBy: 'parent'
- $cascade: ["persist", "remove"]
- $orphanRemoval: true
- $fetch: "LAZY"
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
$thiscallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getActive()
public
getActive() : bool
Return values
boolgetAllTraits()
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
stringgetId()
public
getId() : int|null
Return values
int|nullgetSort()
public
getSort() : int
Return values
intgetTranslation()
public
getTranslation(int $langId) : TTranslation|null
Parameters
- $langId : int
Return values
TTranslation|nullgetTranslations()
public
getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>isActive()
public
isActive() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thissetActive()
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
$thissetSort()
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
$thistranslationCollectionInit()
public
translationCollectionInit() : void
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>