CustomAsset
extends CustomAsset
in package
Front end variant of custom code, hydrated from `api/system/custom-asset` through ApiBridge. Read by the `frontSystemCustomAssets` component on every page render.
Attributes
- #[Entity]
- #[Table]
- $name: 'cms_system_custom_assets'
- #[TableAlias]
- 'customAsset'
Table of Contents
Properties
- $active : bool
- $addToNewPages : bool
- A newly created page gets this snippet assigned automatically.
- $code : string
- $cookieCategory : string
- $id : int|null
- $insertTime : DateTime
- $name : string
- $pages : Collection
- Pages the code runs on; the relation alone decides it.
- $placement : string
- $sort : int
- $type : string
- $updateDatetime : DateTime|null
Methods
- __construct() : mixed
- addPage() : $this
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getActive() : bool
- getAddToNewPages() : bool
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getCode() : string
- getCookieCategory() : string
- getId() : int|null
- getInsertTime() : DateTime
- getName() : string
- getPage() : TPage|null
- getPages() : Collection<int, TPage>
- getPlacement() : string
- getPlacementEnum() : CustomAssetPlacement|null
- getSort() : int
- getType() : string
- getTypeEnum() : CustomAssetType|null
- getUpdateDatetime() : DateTime|null
- isActive() : bool
- isAddToNewPages() : bool
- isPersisted() : bool
- needsCookieConsent() : bool
- An empty category means the code runs without waiting for cookie consent.
- pageCollectionInit() : void
- removePage() : $this
- setActive() : $this
- setAddToNewPages() : $this
- setCode() : $this
- setCookieCategory() : $this
- setId() : $this
- setInsertTime() : $this
- setName() : $this
- setPages() : $this
- setPlacement() : $this
- setSort() : $this
- setType() : $this
- setUpdateDatetime() : $this
- 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'
$addToNewPages
A newly created page gets this snippet assigned automatically.
protected
bool
$addToNewPages
= false
Attributes
- #[Column]
- $name: 'add_to_new_pages'
- $type: 'boolean'
$code
protected
string
$code
= ''
Attributes
- #[Column]
- $name: 'code'
- $type: 'text'
$cookieCategory
protected
string
$cookieCategory
= ''
Attributes
- #[Column]
- $name: 'cookie_category'
- $type: 'string'
- $length: 20
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'custom_asset_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$insertTime
protected
DateTime
$insertTime
= new DateTime()
Attributes
- #[Column]
- $name: 'insert_time'
- $type: 'datetime'
$name
protected
string
$name
= ''
Attributes
- #[Column]
- $name: 'name'
- $type: 'string'
- $length: 255
$pages
Pages the code runs on; the relation alone decides it.
protected
Collection
$pages
IMPORTANT: the asset owns the relation, not the page (Page knows nothing about assets).
The relations are not saved through this collection (a generic save would delete them via
extract) but by the Api operations sync-page / attach-all-pages / detach-all-pages.
There is no @var Collection<int, Page>: narrowing against the shared entity is
non-covariant for PHPStan. The element class is governed by #[CollectionOf] (hydrator)
and targetEntity (Doctrine) anyway.
Attributes
- #[CollectionOf]
- \App\UI\Front\System\Models\Entities\Page::class
- #[JoinTable]
- $name: 'cms_system_custom_asset_page_relations'
- $joinColumns: [new \Doctrine\ORM\Mapping\JoinColumn(name: 'cms_system_custom_assets_custom_asset_id', referencedColumnName: 'custom_asset_id')]
- $inverseJoinColumns: [new \Doctrine\ORM\Mapping\JoinColumn(name: 'cms_system_pages_page_id', referencedColumnName: 'page_id')]
- #[ManyToMany]
- $targetEntity: \App\UI\Front\System\Models\Entities\Page::class
- $fetch: 'LAZY'
$placement
protected
string
$placement
= CustomAssetPlacement::BodyEnd->value
Attributes
- #[Column]
- $name: 'placement'
- $type: 'string'
- $length: 15
$sort
protected
int
$sort
= 0
Attributes
- #[Column]
- $name: 'sort'
- $type: 'integer'
- $options: ['unsigned' => true]
$type
protected
string
$type
= CustomAssetType::Js->value
Attributes
- #[Column]
- $name: 'type'
- $type: 'string'
- $length: 10
$updateDatetime
protected
DateTime|null
$updateDatetime
= null
Attributes
- #[Column]
- $name: 'update_datetime'
- $type: 'datetime'
- $nullable: true
Methods
__construct()
public
__construct([int|null $id = null ][, string $name = '' ][, string $type = CustomAssetType::Js->value ][, string $placement = CustomAssetPlacement::BodyEnd->value ][, string $cookieCategory = '' ][, string $code = '' ][, bool $active = true ][, int $sort = 0 ][, bool $addToNewPages = false ][, DateTime $insertTime = new DateTime() ][, DateTime|null $updateDatetime = null ][, Collection $pages = new ArrayCollection() ]) : mixed
Parameters
- $id : int|null = null
- $name : string = ''
- $type : string = CustomAssetType::Js->value
- $placement : string = CustomAssetPlacement::BodyEnd->value
- $cookieCategory : string = ''
- $code : string = ''
- $active : bool = true
- $sort : int = 0
- $addToNewPages : bool = false
- $insertTime : DateTime = new DateTime()
- $updateDatetime : DateTime|null = null
- $pages : Collection = new ArrayCollection()
addPage()
public
addPage(TPage $page) : $this
Parameters
- $page : TPage
Return values
$thiscallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getActive()
public
getActive() : bool
Return values
boolgetAddToNewPages()
public
getAddToNewPages() : 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>getCode()
public
getCode() : string
Return values
stringgetCookieCategory()
public
getCookieCategory() : string
Return values
stringgetId()
public
getId() : int|null
Return values
int|nullgetInsertTime()
public
getInsertTime() : DateTime
Return values
DateTimegetName()
public
getName() : string
Return values
stringgetPage()
public
getPage(int $pageId) : TPage|null
Parameters
- $pageId : int
Return values
TPage|nullgetPages()
public
getPages() : Collection<int, TPage>
Return values
Collection<int, TPage>getPlacement()
public
getPlacement() : string
Return values
stringgetPlacementEnum()
public
getPlacementEnum() : CustomAssetPlacement|null
Return values
CustomAssetPlacement|nullgetSort()
public
getSort() : int
Return values
intgetType()
public
getType() : string
Return values
stringgetTypeEnum()
public
getTypeEnum() : CustomAssetType|null
Return values
CustomAssetType|nullgetUpdateDatetime()
public
getUpdateDatetime() : DateTime|null
Return values
DateTime|nullisActive()
public
isActive() : bool
Return values
boolisAddToNewPages()
public
isAddToNewPages() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolneedsCookieConsent()
An empty category means the code runs without waiting for cookie consent.
public
needsCookieConsent() : bool
NOTE: only "something is filled in" is checked, not whether the category exists in the cookie bar; the entity does not know the configuration. Validity is guarded by the form select, which offers exactly the bar categories (CookieConsentConfig::selectableKeys()).
Return values
boolpageCollectionInit()
public
pageCollectionInit() : void
removePage()
public
removePage(TPage $page) : $this
Parameters
- $page : TPage
Return values
$thissetActive()
public
setActive(bool $active) : $this
Parameters
- $active : bool
Return values
$thissetAddToNewPages()
public
setAddToNewPages(bool $addToNewPages) : $this
Parameters
- $addToNewPages : bool
Return values
$thissetCode()
public
setCode(string $code) : $this
Parameters
- $code : string
Return values
$thissetCookieCategory()
public
setCookieCategory(string $cookieCategory) : $this
Parameters
- $cookieCategory : string
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetInsertTime()
public
setInsertTime(DateTime $insertTime) : $this
Parameters
- $insertTime : DateTime
Return values
$thissetName()
public
setName(string $name) : $this
Parameters
- $name : string
Return values
$thissetPages()
public
setPages(Collection<int, TPage>|array<int, TPage> $pages) : $this
Parameters
- $pages : Collection<int, TPage>|array<int, TPage>
Return values
$thissetPlacement()
public
setPlacement(string $placement) : $this
Parameters
- $placement : string
Return values
$thissetSort()
public
setSort(int $sort) : $this
Parameters
- $sort : int
Return values
$thissetType()
public
setType(string $type) : $this
Parameters
- $type : string
Return values
$thissetUpdateDatetime()
public
setUpdateDatetime(DateTime|null $updateDatetime) : $this
Parameters
- $updateDatetime : DateTime|null
Return values
$thisgetTraitsRecursive()
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>