Gift
extends Gift
in package
Gift: a free gift added to an order. It has two links to product sets: - `$productSet`: the gift is itself a sellable product set (nullable; the alternative is a purely named gift with an `$image`), - `$offerSets`: many-to-many, the gift is offered when buying the set (edited in the product set form).
Tags
Attributes
- #[Entity]
- #[Table]
- $name: 'cms_mod_eshop_gifts'
- #[TableAlias]
- 'gift'
Table of Contents
Properties
- $amount : int
- $available : bool
- $availableForOrder : bool
- $endDatetime : DateTime|null
- $hidden : bool
- $id : int|null
- $image : TImage|null
- $insertDatetime : DateTime|null
- $offerSets : Collection<int, ProductSet>
- $prices : Collection<int, GiftPrice>
- $priority : int
- $productSet : TProductSet|null
- $startDatetime : DateTime|null
- $translations : Collection<int, GiftText>
Methods
- __construct() : mixed
- addOfferSet() : $this
- addPrice() : $this
- addTranslation() : $this
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAmount() : int
- getAvailable() : bool
- getAvailableForOrder() : bool
- getEndDatetime() : DateTime|null
- getHidden() : bool
- getId() : int|null
- getImage() : TImage|null
- getInsertDatetime() : DateTime|null
- getOfferSets() : Collection<int, TOfferSet>
- getPriceForCurrency() : TPrice|null
- Returns the gift's price/threshold row for the currency, or null when there is none.
- getPrices() : Collection<int, TPrice>
- getPriority() : int
- getProductSet() : TProductSet|null
- getStartDatetime() : DateTime|null
- getTranslation() : TTranslation|null
- getTranslations() : Collection<int, TTranslation>
- isAvailable() : bool
- isHidden() : bool
- isPersisted() : bool
- removeTranslation() : $this
- setAmount() : $this
- setAvailable() : $this
- setAvailableForOrder() : $this
- setEndDatetime() : $this
- setHidden() : $this
- setId() : $this
- setImage() : $this
- setInsertDatetime() : $this
- setOfferSets() : $this
- setPrices() : $this
- setPriority() : $this
- setProductSet() : $this
- setStartDatetime() : $this
- setTranslations() : $this
- translationCollectionInit() : void
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$amount
protected
int
$amount
= 1
Attributes
- #[Column]
- $name: 'amount'
- $type: 'integer'
- $options: ['unsigned' => true]
$available
protected
bool
$available
= true
Attributes
- #[Column]
- $name: 'available'
- $type: 'boolean'
$availableForOrder
protected
bool
$availableForOrder
= true
Attributes
- #[Column]
- $name: 'available_for_order'
- $type: 'boolean'
$endDatetime
protected
DateTime|null
$endDatetime
= null
Attributes
- #[Column]
- $name: 'end_datetime'
- $type: 'datetime'
- $nullable: true
$hidden
protected
bool
$hidden
= false
Attributes
- #[Column]
- $name: 'hidden'
- $type: 'boolean'
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'gift_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$image
protected
TImage|null
$image
= null
Attributes
- #[JoinColumn]
- $name: 'cms_system_images_image_id'
- $referencedColumnName: 'image_id'
- $nullable: true
- $onDelete: 'SET NULL'
- #[ManyToOne]
- $targetEntity: \App\UI\Api\System\Models\Entities\Asset::class
- $fetch: 'LAZY'
$insertDatetime
protected
DateTime|null
$insertDatetime
= null
Attributes
- #[Column]
- $name: 'insert_datetime'
- $type: 'datetime'
$offerSets
protected
Collection<int, ProductSet>
$offerSets
M:N, product sets the gift is offered with
Attributes
- #[InverseJoinColumn]
- $name: 'cms_mod_eshop_product_sets_product_set_id'
- $referencedColumnName: 'product_set_id'
- $onDelete: 'CASCADE'
- #[JoinColumn]
- $name: 'cms_mod_eshop_gifts_gift_id'
- $referencedColumnName: 'gift_id'
- $onDelete: 'CASCADE'
- #[JoinTable]
- $name: 'cms_mod_eshop_gift_product_set_rel'
- #[ManyToMany]
- $targetEntity: \App\UI\Api\Eshop\Models\Entities\ProductSet::class
- $fetch: 'LAZY'
$prices
protected
Collection<int, GiftPrice>
$prices
Attributes
- #[OneToMany]
- $targetEntity: \App\UI\Api\Eshop\Models\Entities\GiftPrice::class
- $mappedBy: 'gift'
- $cascade: ['persist', 'remove']
- $orphanRemoval: true
- $fetch: 'LAZY'
$priority
protected
int
$priority
= 0
Attributes
- #[Column]
- $name: 'priority'
- $type: 'integer'
$productSet
protected
TProductSet|null
$productSet
= null
the gift is this set (null = purely named gift)
Attributes
- #[JoinColumn]
- $name: 'cms_mod_eshop_product_sets_product_set_id'
- $referencedColumnName: 'product_set_id'
- $nullable: true
- $onDelete: 'SET NULL'
- #[ManyToOne]
- $targetEntity: \App\UI\Api\Eshop\Models\Entities\ProductSet::class
- $fetch: 'LAZY'
$startDatetime
protected
DateTime|null
$startDatetime
= null
Attributes
- #[Column]
- $name: 'start_datetime'
- $type: 'datetime'
$translations
protected
Collection<int, GiftText>
$translations
Attributes
- #[OneToMany]
- $targetEntity: \App\UI\Api\Eshop\Models\Entities\GiftText::class
- $mappedBy: 'parent'
- $cascade: ['persist', 'remove']
- $orphanRemoval: true
- $fetch: 'LAZY'
Methods
__construct()
public
__construct([int|null $id = null ][, DateTime|null $startDatetime = null ][, DateTime|null $endDatetime = null ][, mixed $productSet = null ][, mixed $image = null ][, bool $available = true ][, bool $availableForOrder = true ][, bool $hidden = false ][, int $priority = 0 ][, int $amount = 1 ][, DateTime|null $insertDatetime = null ][, Collection $translations = new ArrayCollection() ][, Collection $prices = new ArrayCollection() ][, Collection $offerSets = new ArrayCollection() ]) : mixed
Parameters
- $id : int|null = null
- $startDatetime : DateTime|null = null
- $endDatetime : DateTime|null = null
- $productSet : mixed = null
- $image : mixed = null
- $available : bool = true
- $availableForOrder : bool = true
- $hidden : bool = false
- $priority : int = 0
- $amount : int = 1
- $insertDatetime : DateTime|null = null
- $translations : Collection = new ArrayCollection()
- $prices : Collection = new ArrayCollection()
- $offerSets : Collection = new ArrayCollection()
addOfferSet()
public
addOfferSet(TOfferSet $offerSet) : $this
Parameters
- $offerSet : TOfferSet
Return values
$thisaddPrice()
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
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>getAmount()
public
getAmount() : int
Return values
intgetAvailable()
public
getAvailable() : bool
Return values
boolgetAvailableForOrder()
public
getAvailableForOrder() : bool
Return values
boolgetEndDatetime()
public
getEndDatetime() : DateTime|null
Return values
DateTime|nullgetHidden()
public
getHidden() : bool
Return values
boolgetId()
public
getId() : int|null
Return values
int|nullgetImage()
public
getImage() : TImage|null
Return values
TImage|nullgetInsertDatetime()
public
getInsertDatetime() : DateTime|null
Return values
DateTime|nullgetOfferSets()
public
getOfferSets() : Collection<int, TOfferSet>
Return values
Collection<int, TOfferSet>getPriceForCurrency()
Returns the gift's price/threshold row for the currency, or null when there is none.
public
getPriceForCurrency(int $currencyId) : TPrice|null
Parameters
- $currencyId : int
Return values
TPrice|nullgetPrices()
public
getPrices() : Collection<int, TPrice>
Return values
Collection<int, TPrice>getPriority()
public
getPriority() : int
Return values
intgetProductSet()
public
getProductSet() : TProductSet|null
Return values
TProductSet|nullgetStartDatetime()
public
getStartDatetime() : DateTime|null
Return values
DateTime|nullgetTranslation()
public
getTranslation(int $langId) : TTranslation|null
Parameters
- $langId : int
Return values
TTranslation|nullgetTranslations()
public
getTranslations() : Collection<int, TTranslation>
Return values
Collection<int, TTranslation>isAvailable()
public
isAvailable() : bool
Return values
boolisHidden()
public
isHidden() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thissetAmount()
public
setAmount(int $amount) : $this
Parameters
- $amount : int
Return values
$thissetAvailable()
public
setAvailable(bool $available) : $this
Parameters
- $available : bool
Return values
$thissetAvailableForOrder()
public
setAvailableForOrder(bool $availableForOrder) : $this
Parameters
- $availableForOrder : bool
Return values
$thissetEndDatetime()
public
setEndDatetime(DateTime|null $endDatetime) : $this
Parameters
- $endDatetime : DateTime|null
Return values
$thissetHidden()
public
setHidden(bool $hidden) : $this
Parameters
- $hidden : bool
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetImage()
public
setImage(TImage|null $image) : $this
Parameters
- $image : TImage|null
Return values
$thissetInsertDatetime()
public
setInsertDatetime(DateTime|null $insertDatetime) : $this
Parameters
- $insertDatetime : DateTime|null
Return values
$thissetOfferSets()
public
setOfferSets(Collection<int, TOfferSet>|array<int, TOfferSet> $offerSets) : $this
Parameters
- $offerSets : Collection<int, TOfferSet>|array<int, TOfferSet>
Return values
$thissetPrices()
public
setPrices(Collection<int, TPrice>|array<int, TPrice> $prices) : $this
Parameters
- $prices : Collection<int, TPrice>|array<int, TPrice>
Return values
$thissetPriority()
public
setPriority(int $priority) : $this
Parameters
- $priority : int
Return values
$thissetProductSet()
public
setProductSet(TProductSet|null $productSet) : $this
Parameters
- $productSet : TProductSet|null
Return values
$thissetStartDatetime()
public
setStartDatetime(DateTime|null $startDatetime) : $this
Parameters
- $startDatetime : DateTime|null
Return values
$thissetTranslations()
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>