CoolCMS API

Block extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait, TranslationCollectionTrait

AbstractYes

Content block of the company presentation: a free-form HTML section (for example "About us").

The content is ready-made HTML entered by an editor in the admin; the template only prints it.

IMPORTANT: content is printed unescaped (|noescape) on the front end, so only a trusted role with admin privileges may fill it. Never use it for anything that comes from a visitor, otherwise it is an XSS hole.

Structured like Highlight: a standalone mini entity with a scalar companyId (not an ORM association to Company), translations in _texts. The admin therefore does not save it through the company object graph but with a separate sync, see CompanyFormTrait::saveBlocks().

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

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

$companyId  : int
$deleted  : bool
$id  : int|null
$identifier  : string|null
$order  : int
$public  : bool
$translations  : Collection<int, TTranslation>

Methods

__construct()  : mixed
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.
getCompanyId()  : int
getDeleted()  : bool
getId()  : int|null
getIdentifier()  : string|null
getOrder()  : int
getPublic()  : bool
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
isDeleted()  : bool
isPersisted()  : bool
isPublic()  : bool
removeTranslation()  : $this
setCompanyId()  : $this
setDeleted()  : $this
setId()  : $this
setIdentifier()  : $this
setOrder()  : $this
setPublic()  : $this
setTranslations()  : $this
translationCollectionInit()  : void
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$companyId

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

$deleted

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

$id

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

$identifier

protected string|null $identifier = null
Attributes
#[Column]
$name: 'identifier'
$type: 'string'
$length: 50
$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'

Methods

__construct()

public __construct([int|null $id = null ][, int $companyId = 0 ][, string|null $identifier = null ][, int $order = 0 ][, bool $public = true ][, bool $deleted = false ]) : mixed
Parameters
$id : int|null = null
$companyId : int = 0
$identifier : string|null = null
$order : int = 0
$public : bool = true
$deleted : bool = false

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>

getCompanyId()

public getCompanyId() : int
Return values
int

getDeleted()

public getDeleted() : bool
Return values
bool

getIdentifier()

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

getOrder()

public getOrder() : int
Return values
int

getPublic()

public getPublic() : bool
Return values
bool

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>

isDeleted()

public isDeleted() : bool
Return values
bool

isPublic()

public isPublic() : bool
Return values
bool

removeTranslation()

public removeTranslation(TTranslation $translation) : $this
Parameters
$translation : TTranslation
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

setId()

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

setIdentifier()

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

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