Tariff
extends Tariff
in package
Admin variant of a tariff (`cms_system_user_tariffs`), hydrated from the Api endpoint `api/system/tariff`; maps translations and the price list (`TariffPrice` per region and gateway; the currency is the front end axis).
Tags
Attributes
- #[Entity]
- #[Table]
- $name: 'cms_system_user_tariffs'
- #[TableAlias]
- 'tariff'
Table of Contents
Properties
- $active : bool
- $credits : int
- $duration : int
- $id : int|null
- $prices : Collection<int, TariffPrice>
- $productTypeId : int|null
- $supplyKindId : int|null
- $translations : Collection
- $vatPercents : numeric-string|null
Methods
- __construct() : mixed
- addPrice() : $this
- addTranslation() : $this
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- clearPrices() : $this
- getActive() : bool
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getCredits() : int
- getDuration() : int
- getId() : int|null
- getPrice() : TPrice|null
- getPrices() : Collection<int, TPrice>
- getProductTypeId() : int|null
- getSupplyKindId() : int|null
- getTranslation() : TTranslation|null
- getTranslations() : Collection<int, TTranslation>
- getVatPercents() : numeric-string|null
- isActive() : bool
- isPersisted() : bool
- removePrice() : $this
- removeTranslation() : $this
- setActive() : $this
- setCredits() : $this
- setDuration() : $this
- setId() : $this
- setPrices() : $this
- IMPORTANT: the parameter type must be `Collection`, not `ArrayCollection`; the keep branch of the Api `SaveTrait` passes a `PersistentCollection` from a managed entity, and a narrower type throws a `TypeError` and fails the tariff save in the admin.
- setProductTypeId() : TPriceRel>
- setSupplyKindId() : TPriceRel>
- setTranslations() : $this
- setVatPercents() : TPriceRel>
- tariffPriceCollectionInit() : void
- translationCollectionInit() : void
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$active
protected
bool
$active
= true
Attributes
- #[Column]
- $type: "boolean"
- $name: "active"
- $options: ["default" => 1]
$credits
protected
int
$credits
= 0
Attributes
- #[Column]
- $type: "integer"
- $name: "credits"
- $options: ["default" => 0]
$duration
protected
int
$duration
= 7
Attributes
- #[Column]
- $type: "integer"
- $name: "duration"
- $options: ["default" => 7]
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $type: "integer"
- $name: "user_tariff_id"
- #[GeneratedValue]
- #[Id]
$prices
protected
Collection<int, TariffPrice>
$prices
Attributes
- #[CollectionOf]
- \App\UI\Admin\System\Models\Entities\TariffPrice::class
- $owned: true
- #[OneToMany]
- $targetEntity: \App\UI\Admin\System\Models\Entities\TariffPrice::class
- $mappedBy: 'tariff'
- $cascade: ["persist", "remove"]
- $orphanRemoval: true
- $fetch: "LAZY"
$productTypeId
protected
int|null
$productTypeId
= null
Attributes
- #[Column]
- $type: "integer"
- $name: "cms_mod_invoicer_product_types_product_type_id"
- $nullable: true
- $options: ["unsigned" => true]
$supplyKindId
protected
int|null
$supplyKindId
= null
Attributes
- #[Column]
- $name: 'cms_system_supply_kinds_supply_kind_id'
- $type: 'integer'
- $nullable: true
- $options: ['unsigned' => true]
$translations
protected
Collection
$translations
Attributes
- #[CollectionOf]
- \App\UI\Admin\System\Models\Entities\TariffText::class
- $owned: true
- #[OneToMany]
- $targetEntity: \App\UI\Admin\System\Models\Entities\TariffText::class
- $mappedBy: 'parent'
- $cascade: ["persist", "remove"]
- $orphanRemoval: true
- $fetch: "LAZY"
$vatPercents
protected
numeric-string|null
$vatPercents
= null
Attributes
- #[Column]
- $type: "decimal"
- $precision: 5
- $scale: 2
- $name: "vat_percents"
- $nullable: true
Methods
__construct()
public
__construct([int|null $id = null ][, int $duration = 7 ][, int $credits = 0 ][, bool $active = true ][, int|null $productTypeId = null ][, string|null $vatPercents = null ][, Collection $translations = new ArrayCollection() ][, Collection $prices = new ArrayCollection() ][, int|null $supplyKindId = null ]) : mixed
Parameters
- $id : int|null = null
- $duration : int = 7
- $credits : int = 0
- $active : bool = true
- $productTypeId : int|null = null
- $vatPercents : string|null = null
- $translations : Collection = new ArrayCollection()
- $prices : Collection = new ArrayCollection()
- $supplyKindId : int|null = null
addPrice()
public
addPrice(TPrice $price) : $this
Parameters
- $price : TPrice
Return values
$thisaddTranslation()
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
clearPrices()
public
clearPrices() : $this
Return values
$thisgetActive()
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>getCredits()
public
getCredits() : int
Return values
intgetDuration()
public
getDuration() : int
Return values
intgetId()
public
getId() : int|null
Return values
int|nullgetPrice()
public
getPrice([int|null $paymentRegionId = null ][, int|null $paymentGateId = null ][, int|null $currencyId = null ]) : TPrice|null
Parameters
- $paymentRegionId : int|null = null
- $paymentGateId : int|null = null
- $currencyId : int|null = null
Return values
TPrice|nullgetPrices()
public
getPrices() : Collection<int, TPrice>
Return values
Collection<int, TPrice>getProductTypeId()
public
getProductTypeId() : int|null
Return values
int|nullgetSupplyKindId()
public
getSupplyKindId() : int|null
Return values
int|nullgetTranslation()
public
getTranslation(int $langId) : TTranslation|null
Parameters
- $langId : int
Return values
TTranslation|nullgetTranslations()
public
getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>getVatPercents()
public
getVatPercents() : numeric-string|null
Return values
numeric-string|nullisActive()
public
isActive() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolremovePrice()
public
removePrice(TPrice $price) : $this
Parameters
- $price : TPrice
Return values
$thisremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thissetActive()
public
setActive(bool $active) : $this
Parameters
- $active : bool
Return values
$thissetCredits()
public
setCredits(int $credits) : $this
Parameters
- $credits : int
Return values
$thissetDuration()
public
setDuration(int $duration) : $this
Parameters
- $duration : int
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetPrices()
IMPORTANT: the parameter type must be `Collection`, not `ArrayCollection`; the keep branch of the Api `SaveTrait` passes a `PersistentCollection` from a managed entity, and a narrower type throws a `TypeError` and fails the tariff save in the admin.
public
setPrices(Collection<int, TPrice> $prices) : $this
Parameters
- $prices : Collection<int, TPrice>
Return values
$thissetProductTypeId()
public
setProductTypeId(int|null $productTypeId) : TPriceRel>
Parameters
- $productTypeId : int|null
Return values
TPriceRel>setSupplyKindId()
public
setSupplyKindId(int|null $supplyKindId) : TPriceRel>
Parameters
- $supplyKindId : int|null
Return values
TPriceRel>setTranslations()
public
setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
- $translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$thissetVatPercents()
public
setVatPercents(int|float|string|null $vatPercents) : TPriceRel>
Parameters
- $vatPercents : int|float|string|null
Return values
TPriceRel>tariffPriceCollectionInit()
public
tariffPriceCollectionInit() : void
translationCollectionInit()
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>