CoolCMS API

Tariff extends Tariff
in package

Admin variant of an advert tariff, hydrated from `api/bazaar/tariff`.

Maps the translations (name, title, description), the prices per payment region and gateway, and the express prices per payment region. Region, gateway and currency are scalar FKs in the prices (mirrors the Front).

Tags
extends
Attributes
#[Entity]
#[Table]
$name: 'cms_mod_bazaar_advert_tariffs'
#[TableAlias]
'tariff'

Table of Contents

Properties

$active  : bool
$credits  : int
$duration  : int
$id  : int|null
$prices  : Collection<int, TariffPrice>
$productTypeId  : int|null
$quickPrices  : Collection<int, TariffQuickPrice>
$supplyKindId  : int|null
$translations  : Collection<int, TariffText>
$vatPercents  : numeric-string|null

Methods

__construct()  : mixed
addPrice()  : $this
addQuickPrice()  : $this
addTranslation()  : $this
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
clearPrices()  : $this
clearQuickPrices()  : $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
getQuickPrice()  : TQuickPrice|null
getQuickPrices()  : Collection<int, TQuickPrice>
getSupplyKindId()  : int|null
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
getVatPercents()  : numeric-string|null
isActive()  : bool
isPersisted()  : bool
removePrice()  : $this
removeQuickPrice()  : $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()  : TQuickPrice>
setQuickPrices()  : $this
setSupplyKindId()  : TQuickPrice>
setTranslations()  : $this
setVatPercents()  : TQuickPrice>
tariffPriceCollectionInit()  : void
tariffQuickPriceCollectionInit()  : 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]
$name: 'active'
$type: 'boolean'

$credits

protected int $credits = 0
Attributes
#[Column]
$name: 'credits'
$type: 'integer'
$options: ['unsigned' => true]

$duration

protected int $duration = 0
Attributes
#[Column]
$name: 'duration'
$type: 'integer'
$options: ['unsigned' => true]

$id

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

$prices

protected Collection<int, TariffPrice> $prices
Attributes
#[CollectionOf]
\App\UI\Admin\Bazaar\Models\Entities\TariffPrice::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Bazaar\Models\Entities\TariffPrice::class
$mappedBy: 'tariff'
$cascade: ["persist", "remove"]
$orphanRemoval: true
$fetch: "LAZY"

$productTypeId

protected int|null $productTypeId = null
Attributes
#[Column]
$name: 'cms_mod_invoicer_product_types_product_type_id'
$type: 'integer'
$nullable: true
$options: ['unsigned' => true]

$quickPrices

protected Collection<int, TariffQuickPrice> $quickPrices
Attributes
#[CollectionOf]
\App\UI\Admin\Bazaar\Models\Entities\TariffQuickPrice::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Bazaar\Models\Entities\TariffQuickPrice::class
$mappedBy: 'tariff'
$cascade: ["persist", "remove"]
$orphanRemoval: true
$fetch: "LAZY"

$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<int, TariffText> $translations
Attributes
#[CollectionOf]
\App\UI\Admin\Bazaar\Models\Entities\TariffText::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Bazaar\Models\Entities\TariffText::class
$mappedBy: 'parent'
$cascade: ["persist", "remove"]
$orphanRemoval: true
$fetch: "LAZY"

$vatPercents

protected numeric-string|null $vatPercents = null
Attributes
#[Column]
$name: 'vat_percents'
$type: 'decimal'
$precision: 5
$scale: 2
$nullable: true

Methods

__construct()

public __construct([int|null $id = null ][, int $duration = 0 ][, int $credits = 0 ][, bool $active = true ][, int|null $productTypeId = null ][, string|null $vatPercents = null ][, Collection $translations = new ArrayCollection() ][, Collection $prices = new ArrayCollection() ][, Collection $quickPrices = new ArrayCollection() ][, int|null $supplyKindId = null ]) : mixed
Parameters
$id : int|null = null
$duration : int = 0
$credits : int = 0
$active : bool = true
$productTypeId : int|null = null
$vatPercents : string|null = null
$translations : Collection = new ArrayCollection()
$prices : Collection = new ArrayCollection()
$quickPrices : Collection = new ArrayCollection()
$supplyKindId : int|null = null

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>

getCredits()

public getCredits() : int
Return values
int

getDuration()

public getDuration() : int
Return values
int

getPrice()

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|null

getProductTypeId()

public getProductTypeId() : int|null
Return values
int|null

getQuickPrice()

public getQuickPrice(int $paymentRegionId) : TQuickPrice|null
Parameters
$paymentRegionId : int
Return values
TQuickPrice|null

getSupplyKindId()

public getSupplyKindId() : int|null
Return values
int|null

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>

getVatPercents()

public getVatPercents() : numeric-string|null
Return values
numeric-string|null

isActive()

public isActive() : bool
Return values
bool

removeQuickPrice()

public removeQuickPrice(TQuickPrice $quickPrice) : $this
Parameters
$quickPrice : TQuickPrice
Return values
$this

removeTranslation()

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

setActive()

public setActive(bool $active) : $this
Parameters
$active : bool
Return values
$this

setCredits()

public setCredits(int $credits) : $this
Parameters
$credits : int
Return values
$this

setDuration()

public setDuration(int $duration) : $this
Parameters
$duration : int
Return values
$this

setId()

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

setPrices()

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
$this

setProductTypeId()

public setProductTypeId(int|null $productTypeId) : TQuickPrice>
Parameters
$productTypeId : int|null
Return values
TQuickPrice>

setQuickPrices()

public setQuickPrices(Collection<int, TQuickPrice>|array<int, TQuickPrice> $quickPrices) : $this
Parameters
$quickPrices : Collection<int, TQuickPrice>|array<int, TQuickPrice>
Return values
$this

setSupplyKindId()

public setSupplyKindId(int|null $supplyKindId) : TQuickPrice>
Parameters
$supplyKindId : int|null
Return values
TQuickPrice>

setTranslations()

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

setVatPercents()

public setVatPercents(int|float|string|null $vatPercents) : TQuickPrice>
Parameters
$vatPercents : int|float|string|null
Return values
TQuickPrice>

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