Gallery
extends BaseEntity
in package
implements
IdentifiableInterface
uses
IdentifiableTrait, TranslationCollectionTrait, AssetRelCollectionTrait, CategoryCollectionTrait
Tags
Attributes
- #[MappedSuperclass]
- #[TableAlias]
- $alias: 'gallery'
Table of Contents
Interfaces
- IdentifiableInterface
- Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).
Properties
- $activated : bool
- $assetRels : Collection<int, TAssetRel>
- $categories : Collection<int, TCategory>
- $commentThread : TCommentThread|null
- Comment thread: an object ManyToOne association (FK `cms_mod_base_{comment,rating}_threads_*_thread_id`) mapped by the concrete UI variant.
- $id : int|null
- $insertDatetime : DateTime
- $onlyForLogged : bool
- $published : DateTime|null
- $ratingThread : TRatingThread|null
- $translations : Collection<int, TTranslation>
- $userId : int|null
Methods
- __construct() : mixed
- addAssetRel() : $this
- addCategory() : $this
- addTranslation() : $this
- assetRelCollectionInit() : void
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- categoryCollectionInit() : void
- clearCategories() : $this
- getActivated() : bool
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAssetRels() : Collection<int, TAssetRel>
- getAssets() : array<int, mixed>
- Assets of the non-removed rels, ordered by `order` — whatever the rel's untyped `getAsset()` holds (asset entity, or null).
- getCategories() : Collection<int, TCategory>
- getCategoryIds() : array<string|int, int>
- getCommentThread() : TCommentThread|null
- getCommentThreadId() : int|null
- getFirstCategoryId() : int|null
- getId() : int|null
- getInsertDatetime() : DateTime
- getMainAsset() : Asset|null
- getOnlyForLogged() : bool
- getPublished() : DateTime|null
- getRatingThread() : TRatingThread|null
- getRatingThreadId() : int|null
- getTranslation() : TTranslation|null
- getTranslations() : Collection<int, TTranslation>
- getUserId() : int|null
- isActivated() : bool
- isOnlyForLogged() : bool
- isPersisted() : bool
- isVisibleFor() : bool
- Whether a visitor may see the gallery where it is attached (article and event detail): active, already published and, with `onlyForLogged`, only for a logged-in visitor. The detail used to print every attached gallery, including disabled, scheduled and logged-in-only ones.
- removeAssetRel() : $this
- removeCategory() : $this
- removeTranslation() : $this
- setActivated() : $this
- setAssetRels() : $this
- IMPORTANT: the parameter type must be `Collection`, not `ArrayCollection`; the keep branch of the Api `SaveTrait` can pass a `PersistentCollection` from a managed entity, and a narrower type would throw a `TypeError` and fail the save.
- setCategories() : $this
- setCommentThread() : $this
- setId() : $this
- setInsertDatetime() : $this
- setOnlyForLogged() : $this
- setPublished() : $this
- setRatingThread() : $this
- setTranslations() : $this
- setUserId() : $this
- translationCollectionInit() : void
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$activated
protected
bool
$activated
= false
Attributes
- #[Column]
- $name: 'activated'
- $type: 'boolean'
$assetRels
protected
Collection<int, TAssetRel>
$assetRels
= new ArrayCollection()
$categories
protected
Collection<int, TCategory>
$categories
= new ArrayCollection()
$commentThread
Comment thread: an object ManyToOne association (FK `cms_mod_base_{comment,rating}_threads_*_thread_id`) mapped by the concrete UI variant.
protected
TCommentThread|null
$commentThread
= null
The API manager creates it idempotently in beforeSave when missing; the scalar
get*ThreadId() is derived from the object.
It is #[Transient] here: the admin variant does not map the association, so the
hydrator must not extract it, otherwise commentThread: null in the payload overwrites
the FK. The Api/Front variants override it by redeclaring with the ORM mapping.
Attributes
- #[Transient]
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'gallery_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$insertDatetime
protected
DateTime
$insertDatetime
= new DateTime()
Attributes
- #[Column]
- $name: 'insert_datetime'
- $type: 'datetime'
$onlyForLogged
protected
bool
$onlyForLogged
= false
Attributes
- #[Column]
- $name: 'only_for_logged'
- $type: 'boolean'
$published
protected
DateTime|null
$published
= null
Attributes
- #[Column]
- $name: 'published'
- $type: 'datetime'
- $nullable: true
$ratingThread
protected
TRatingThread|null
$ratingThread
= null
Attributes
- #[Transient]
$translations
protected
Collection<int, TTranslation>
$translations
= new ArrayCollection()
$userId
protected
int|null
$userId
= null
Attributes
- #[Column]
- $name: 'cms_system_users_user_id'
- $type: 'integer'
- $nullable: true
- $options: ['unsigned' => true]
Methods
__construct()
public
__construct([int|null $id = null ][, int|null $userId = null ][, bool $onlyForLogged = false ][, DateTime $insertDatetime = new DateTime() ][, DateTime|null $published = null ][, bool $activated = false ][, Collection $translations = new ArrayCollection() ][, Collection $assetRels = new ArrayCollection() ][, Collection $categories = new ArrayCollection() ]) : mixed
Parameters
- $id : int|null = null
- $userId : int|null = null
- $onlyForLogged : bool = false
- $insertDatetime : DateTime = new DateTime()
- $published : DateTime|null = null
- $activated : bool = false
- $translations : Collection = new ArrayCollection()
- $assetRels : Collection = new ArrayCollection()
- $categories : Collection = new ArrayCollection()
addAssetRel()
public
addAssetRel(TAssetRel $assetRel) : $this
Parameters
- $assetRel : TAssetRel
Return values
$thisaddCategory()
public
addCategory(TCategory $category) : $this
Parameters
- $category : TCategory
Return values
$thisaddTranslation()
public
addTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thisassetRelCollectionInit()
public
assetRelCollectionInit() : void
callInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
categoryCollectionInit()
public
categoryCollectionInit() : void
clearCategories()
public
clearCategories() : $this
Return values
$thisgetActivated()
public
getActivated() : 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>getAssetRels()
public
getAssetRels() : Collection<int, TAssetRel>
Return values
Collection<int, TAssetRel>getAssets()
Assets of the non-removed rels, ordered by `order` — whatever the rel's untyped `getAsset()` holds (asset entity, or null).
public
getAssets() : array<int, mixed>
Return values
array<int, mixed>getCategories()
public
getCategories() : Collection<int, TCategory>
Return values
Collection<int, TCategory>getCategoryIds()
public
getCategoryIds() : array<string|int, int>
Return values
array<string|int, int>getCommentThread()
public
getCommentThread() : TCommentThread|null
Return values
TCommentThread|nullgetCommentThreadId()
public
getCommentThreadId() : int|null
Return values
int|nullgetFirstCategoryId()
public
getFirstCategoryId() : int|null
Return values
int|nullgetId()
public
getId() : int|null
Return values
int|nullgetInsertDatetime()
public
getInsertDatetime() : DateTime
Return values
DateTimegetMainAsset()
public
getMainAsset() : Asset|null
Return values
Asset|null —main image (else the first non-removed one)
getOnlyForLogged()
public
getOnlyForLogged() : bool
Return values
boolgetPublished()
public
getPublished() : DateTime|null
Return values
DateTime|nullgetRatingThread()
public
getRatingThread() : TRatingThread|null
Return values
TRatingThread|nullgetRatingThreadId()
public
getRatingThreadId() : 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>getUserId()
public
getUserId() : int|null
Return values
int|nullisActivated()
public
isActivated() : bool
Return values
boolisOnlyForLogged()
public
isOnlyForLogged() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolisVisibleFor()
Whether a visitor may see the gallery where it is attached (article and event detail): active, already published and, with `onlyForLogged`, only for a logged-in visitor. The detail used to print every attached gallery, including disabled, scheduled and logged-in-only ones.
public
isVisibleFor(bool $loggedIn[, DateTimeInterface|null $now = null ]) : bool
Parameters
- $loggedIn : bool
- $now : DateTimeInterface|null = null
Return values
boolremoveAssetRel()
public
removeAssetRel(TAssetRel $assetRel) : $this
Parameters
- $assetRel : TAssetRel
Return values
$thisremoveCategory()
public
removeCategory(TCategory $category) : $this
Parameters
- $category : TCategory
Return values
$thisremoveTranslation()
public
removeTranslation(TTranslation $translation) : $this
Parameters
- $translation : TTranslation
Return values
$thissetActivated()
public
setActivated(bool $activated) : $this
Parameters
- $activated : bool
Return values
$thissetAssetRels()
IMPORTANT: the parameter type must be `Collection`, not `ArrayCollection`; the keep branch of the Api `SaveTrait` can pass a `PersistentCollection` from a managed entity, and a narrower type would throw a `TypeError` and fail the save.
public
setAssetRels(Collection<int, TAssetRel> $assetRels) : $this
Parameters
- $assetRels : Collection<int, TAssetRel>
Return values
$thissetCategories()
public
setCategories(Collection<int, TCategory>|array<int, TCategory> $categories) : $this
Parameters
- $categories : Collection<int, TCategory>|array<int, TCategory>
Return values
$thissetCommentThread()
public
setCommentThread(TCommentThread|null $commentThread) : $this
Parameters
- $commentThread : TCommentThread|null
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetInsertDatetime()
public
setInsertDatetime(DateTime $dt) : $this
Parameters
- $dt : DateTime
Return values
$thissetOnlyForLogged()
public
setOnlyForLogged(bool $onlyForLogged) : $this
Parameters
- $onlyForLogged : bool
Return values
$thissetPublished()
public
setPublished(DateTime|null $published) : $this
Parameters
- $published : DateTime|null
Return values
$thissetRatingThread()
public
setRatingThread(TRatingThread|null $ratingThread) : $this
Parameters
- $ratingThread : TRatingThread|null
Return values
$thissetTranslations()
public
setTranslations(Collection<int, TTranslation>|array<int, TTranslation> $translations) : $this
Parameters
- $translations : Collection<int, TTranslation>|array<int, TTranslation>
Return values
$thissetUserId()
public
setUserId(int|null $userId) : $this
Parameters
- $userId : int|null
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>