CoolCMS API

Poll extends Poll
in package
uses PollPlaceCollectionTrait

Admin variant of a poll (`cms_mod_base_polls`), hydrated through the ApiBridge from the `api/base/poll` endpoint.

Maps the question translations (translations), the owned answers (answers, cascade persist/remove) and the relation to poll places (placeRels, owned rows of the join entity PollPlaceRel over cms_mod_base_poll_place_relations). The poll place owns the same rows from its side (PollPlace::$pollRels), so polls and poll places are edited separately; the order of polls within a place is edited on the poll place.

Tags
extends
Attributes
#[Entity]
#[Table]
$name: 'cms_mod_base_polls'
#[TableAlias]
'poll'

Table of Contents

Properties

$active  : bool
$answers  : Collection
$id  : int|null
$placeRels  : Collection<int, PollPlaceRel>
$translations  : Collection

Methods

__construct()  : mixed
addAnswer()  : $this
addPlaceRel()  : $this
addTranslation()  : $this
answerCollectionInit()  : void
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.
getAnswer()  : TAnswer|null
getAnswers()  : Collection<int, TAnswer>
getId()  : int|null
getPlaceRels()  : Collection<int, TRel>
getPollPlaces()  : Collection<int, TPollPlace>
Returns the linked poll places, extracted from `placeRels`.
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
isActive()  : bool
isPersisted()  : bool
removeAnswer()  : $this
removeTranslation()  : $this
setActive()  : $this
setAnswers()  : $this
setId()  : $this
setPlaceRels()  : $this
setTranslations()  : $this
translationCollectionInit()  : void
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$active

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

$answers

protected Collection $answers
Attributes
#[CollectionOf]
\App\UI\Admin\Base\Models\Entities\PollAnswer::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Base\Models\Entities\PollAnswer::class
$mappedBy: 'poll'
$cascade: ["persist", "remove"]
$orphanRemoval: true
$fetch: "LAZY"
#[OrderBy]
['order' => 'ASC']

$id

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

$placeRels

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

$translations

protected Collection $translations
Attributes
#[CollectionOf]
\App\UI\Admin\Base\Models\Entities\PollText::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Base\Models\Entities\PollText::class
$mappedBy: 'parent'
$cascade: ["persist", "remove"]
$orphanRemoval: true
$fetch: "LAZY"

Methods

__construct()

public __construct([int|null $id = null ][, bool $active = false ][, Collection $answers = new ArrayCollection() ][, Collection $translations = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$active : bool = false
$answers : Collection = new ArrayCollection()
$translations : Collection = new ArrayCollection()

addAnswer()

public addAnswer(TAnswer $answer) : $this
Parameters
$answer : TAnswer
Return values
$this

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>

getAnswer()

public getAnswer(int $answerId) : TAnswer|null
Parameters
$answerId : int
Return values
TAnswer|null

getAnswers()

public getAnswers() : Collection<int, TAnswer>
Return values
Collection<int, TAnswer>

getPollPlaces()

Returns the linked poll places, extracted from `placeRels`.

public getPollPlaces() : Collection<int, TPollPlace>
Return values
Collection<int, TPollPlace>

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

removeAnswer()

public removeAnswer(TAnswer $answer) : $this
Parameters
$answer : TAnswer
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

setAnswers()

public setAnswers(Collection<int, TAnswer>|array<int, TAnswer> $answers) : $this
Parameters
$answers : Collection<int, TAnswer>|array<int, TAnswer>
Return values
$this

setId()

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

setPlaceRels()

public setPlaceRels(Collection<int, TRel>|array<int, TRel> $placeRels) : $this
Parameters
$placeRels : Collection<int, TRel>|array<int, TRel>
Return values
$this

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