CoolCMS API

Reference extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait, TranslationCollectionTrait, CategoryCollectionTrait, AssetRelCollectionTrait

AbstractYes

Reference project: a showcase card for the website (client, photo, description, quote).

Two image channels:

  • logoId is the reference logo ($meta['logo'], one image through a plain FK); the front end builds the logo carousel from it,
  • the gallery (assetRels, photos and videos) written through $meta['orderedAssets']; the first item in the order is main and is copied to imageId (the main photo). Same model as Message, except that the main image is kept in a plain FK column instead of an ORM association (ReferenceManager::getMainAssetColumn()).

Visibility: public is the master switch; inLogos, inList and featured are its presentation subsets (supplier logo strip, reference list, selected projects on the home page). The server enforces only public and presented in publicList; the front end filters the subsets (ReferenceManager).

Categories (many-to-many) come from the module lookup Category, typically the technologies used.

Tags
template
Attributes
#[MappedSuperclass]
#[TableAlias]
$alias: 'reference'

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

$assetRels  : Collection<int, TAssetRel>
$categories  : Collection<int, TCategory>
$clientName  : string|null
$companyId  : int
$deleted  : bool
$featured  : bool
$id  : int|null
$imageId  : int|null
$inList  : bool
$inLogos  : bool
$logoId  : int|null
$order  : int
$public  : bool
$realizedDate  : DateTime|null
$translations  : Collection<int, TTranslation>
$url  : string|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
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>
getClientName()  : string|null
getCompanyId()  : int
getDeleted()  : bool
getFeatured()  : bool
getFirstCategoryId()  : int|null
getId()  : int|null
getImageId()  : int|null
getInList()  : bool
getInLogos()  : bool
getLogoId()  : int|null
getMainAsset()  : Asset|null
getOrder()  : int
getPublic()  : bool
getRealizedDate()  : DateTime|null
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
getUrl()  : string|null
isDeleted()  : bool
isFeatured()  : bool
isInList()  : bool
isInLogos()  : bool
isPersisted()  : bool
isPublic()  : bool
removeAssetRel()  : $this
removeCategory()  : $this
removeTranslation()  : $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
setClientName()  : $this
setCompanyId()  : $this
setDeleted()  : $this
setFeatured()  : $this
setId()  : $this
setImageId()  : $this
setInList()  : $this
setInLogos()  : $this
setLogoId()  : $this
setOrder()  : $this
setPublic()  : $this
setRealizedDate()  : $this
setTranslations()  : $this
setUrl()  : $this
translationCollectionInit()  : void
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$assetRels

protected Collection<int, TAssetRel> $assetRels = new ArrayCollection()

$categories

protected Collection<int, TCategory> $categories = new ArrayCollection()

$clientName

protected string|null $clientName = null
Attributes
#[Column]
$name: 'client_name'
$type: 'string'
$length: 255
$nullable: true

$companyId

protected int $companyId = 0
Attributes
#[Column]
$name: 'company_id'
$type: 'integer'
$options: ['unsigned' => true]
protected bool $featured = false
#[Column]
$name: 'featured'
$type: 'boolean'

$id

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

$imageId

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

$inList

protected bool $inList = true
Attributes
#[Column]
$name: 'in_list'
$type: 'boolean'

$inLogos

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

$logoId

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

$order

protected int $order = 0
Attributes
#[Column]
$name: '`order`'
$type: 'integer'
$options: ['unsigned' => true, 'default' => 0]

$public

protected bool $public = true
Attributes
#[Column]
$name: 'public'
$type: 'boolean'

$realizedDate

protected DateTime|null $realizedDate = null
Attributes
#[Column]
$name: 'realized_date'
$type: 'date'
$nullable: true

$url

protected string|null $url = null
Attributes
#[Column]
$name: 'url'
$type: 'string'
$length: 255
$nullable: true

Methods

__construct()

public __construct([int|null $id = null ][, int $companyId = 0 ][, string|null $clientName = null ][, DateTime|null $realizedDate = null ][, string|null $url = null ][, int|null $imageId = null ][, int|null $logoId = null ][, int $order = 0 ][, bool $public = true ][, bool $inLogos = false ][, bool $inList = true ][, bool $featured = false ][, bool $deleted = false ][, Collection $assetRels = new ArrayCollection() ][, Collection $categories = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$companyId : int = 0
$clientName : string|null = null
$realizedDate : DateTime|null = null
$url : string|null = null
$imageId : int|null = null
$logoId : int|null = null
$order : int = 0
$public : bool = true
$inLogos : bool = false
$inList : bool = true
$featured : bool = false
$deleted : bool = false
$assetRels : Collection = new ArrayCollection()
$categories : Collection = new ArrayCollection()

addAssetRel()

public addAssetRel(TAssetRel $assetRel) : $this
Parameters
$assetRel : TAssetRel
Return values
$this

addCategory()

public addCategory(TCategory $category) : $this
Parameters
$category : TCategory
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

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>

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>

getClientName()

public getClientName() : string|null
Return values
string|null

getCompanyId()

public getCompanyId() : int
Return values
int

getDeleted()

public getDeleted() : bool
Return values
bool

getFeatured()

public getFeatured() : bool
Return values
bool

getImageId()

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

getInList()

public getInList() : bool
Return values
bool

getInLogos()

public getInLogos() : bool
Return values
bool

getLogoId()

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

getOrder()

public getOrder() : int
Return values
int

getPublic()

public getPublic() : bool
Return values
bool

getRealizedDate()

public getRealizedDate() : DateTime|null
Return values
DateTime|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>

getUrl()

public getUrl() : string|null
Return values
string|null

isDeleted()

public isDeleted() : bool
Return values
bool

isFeatured()

public isFeatured() : bool
Return values
bool

isInList()

public isInList() : bool
Return values
bool

isInLogos()

public isInLogos() : bool
Return values
bool

isPublic()

public isPublic() : bool
Return values
bool

removeAssetRel()

public removeAssetRel(TAssetRel $assetRel) : $this
Parameters
$assetRel : TAssetRel
Return values
$this

removeCategory()

public removeCategory(TCategory $category) : $this
Parameters
$category : TCategory
Return values
$this

removeTranslation()

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

setAssetRels()

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

setCategories()

public setCategories(Collection<int, TCategory>|array<int, TCategory> $categories) : $this
Parameters
$categories : Collection<int, TCategory>|array<int, TCategory>
Return values
$this

setClientName()

public setClientName(string|null $clientName) : $this
Parameters
$clientName : string|null
Return values
$this

setCompanyId()

public setCompanyId(int $companyId) : $this
Parameters
$companyId : int
Return values
$this

setDeleted()

public setDeleted(bool $deleted) : $this
Parameters
$deleted : bool
Return values
$this

setFeatured()

public setFeatured(bool $featured) : $this
Parameters
$featured : bool
Return values
$this

setId()

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

setImageId()

public setImageId(int|null $imageId) : $this
Parameters
$imageId : int|null
Return values
$this

setInList()

public setInList(bool $inList) : $this
Parameters
$inList : bool
Return values
$this

setInLogos()

public setInLogos(bool $inLogos) : $this
Parameters
$inLogos : bool
Return values
$this

setLogoId()

public setLogoId(int|null $logoId) : $this
Parameters
$logoId : int|null
Return values
$this

setOrder()

public setOrder(int $order) : $this
Parameters
$order : int
Return values
$this

setPublic()

public setPublic(bool $public) : $this
Parameters
$public : bool
Return values
$this

setRealizedDate()

public setRealizedDate(DateTime|null $realizedDate) : $this
Parameters
$realizedDate : DateTime|null
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

setUrl()

public setUrl(string|null $url) : $this
Parameters
$url : string|null
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