CoolCMS API

Category extends BaseEntity
in package
implements TreeNodeInterface, IdentifiableInterface uses AssetPathTrait, IdentifiableTrait, TranslationCollectionTrait

AbstractYes

Blog category as a nested-set tree (`lft`/`rgt`/`level` + `parentId`).

The table holds a single tree, so there is no scope. TreeNodeInterface is the gate that lets the generic save() (SaveTrait) compute lft/rgt/level for a newly inserted category (insertTreeNode()).

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

Table of Contents

Interfaces

TreeNodeInterface
Marker for an entity ordered as a nested set (tree via lft/rgt/level + parentId).
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

$active  : bool
$asset  : TImage|null
$assetPath  : string|null
$forFree  : bool
$iconClass  : string|null
$id  : int|null
$level  : int
$lft  : int
$parentId  : int|null
$preferred  : bool
$rgt  : int
$topedFirst  : bool
$translations  : Collection<int, TTranslation>
$assetFile  : FtpAsset|null
Transient cache of the derived `FtpAsset` (not a database column).

Methods

__construct()  : mixed
addTranslation()  : $this
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.
getAsset()  : TImage|null
getAssetFile()  : FtpAsset|null
Returns the `FtpAsset` derived from the path (lazy, works after Doctrine hydration too).
getAssetPath()  : string|null
getForFree()  : bool
getIconClass()  : string|null
getId()  : int|null
getLevel()  : int
getLft()  : int
getParentId()  : int|null
getPreferred()  : bool
getRgt()  : int
getTopedFirst()  : bool
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
isActive()  : bool
isForFree()  : bool
isPersisted()  : bool
isPreferred()  : bool
isTopedFirst()  : bool
removeTranslation()  : $this
setActive()  : $this
setAsset()  : $this
setAssetPath()  : $this
setForFree()  : $this
setIconClass()  : $this
setId()  : $this
setLevel()  : $this
setLft()  : $this
setParentId()  : $this
setPreferred()  : $this
setRgt()  : $this
setTopedFirst()  : $this
setTranslations()  : $this
translationCollectionInit()  : void
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'
$options: ['default' => true]

$asset

protected TImage|null $asset = null

$assetPath

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

$forFree

protected bool $forFree = true
Attributes
#[Column]
$name: 'for_free'
$type: 'boolean'
$options: ['default' => true]

$iconClass

protected string|null $iconClass = null
Attributes
#[Column]
$name: 'icon_class'
$type: 'string'
$length: 50
$nullable: true

$id

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

$level

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

$lft

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

$parentId

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

$preferred

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

$rgt

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

$topedFirst

protected bool $topedFirst = false
Attributes
#[Column]
$name: 'toped_first'
$type: 'boolean'
$options: ['default' => false]
#[ExternalReadonly]

$translations

protected Collection<int, TTranslation> $translations = new ArrayCollection()

Methods

__construct()

public __construct([int|null $id = null ][, mixed $asset = null ][, string|null $assetPath = null ][, int|null $parentId = null ][, int $lft = 0 ][, int $rgt = 0 ][, int $level = 0 ][, bool $forFree = true ][, bool $topedFirst = false ][, bool $active = true ][, bool $preferred = false ][, string|null $iconClass = null ][, Collection $translations = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$asset : mixed = null
$assetPath : string|null = null
$parentId : int|null = null
$lft : int = 0
$rgt : int = 0
$level : int = 0
$forFree : bool = true
$topedFirst : bool = false
$active : bool = true
$preferred : bool = false
$iconClass : string|null = null
$translations : Collection = new ArrayCollection()

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>

getAsset()

public getAsset() : TImage|null
Return values
TImage|null

getAssetFile()

Returns the `FtpAsset` derived from the path (lazy, works after Doctrine hydration too).

public getAssetFile() : FtpAsset|null
Return values
FtpAsset|null

getAssetPath()

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

getForFree()

public getForFree() : bool
Return values
bool

getIconClass()

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

getLevel()

public getLevel() : int
Return values
int

getLft()

public getLft() : int
Return values
int

getParentId()

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

getPreferred()

public getPreferred() : bool
Return values
bool

getRgt()

public getRgt() : int
Return values
int

getTopedFirst()

public getTopedFirst() : 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>

isActive()

public isActive() : bool
Return values
bool

isForFree()

public isForFree() : bool
Return values
bool

isPreferred()

public isPreferred() : bool
Return values
bool

isTopedFirst()

public isTopedFirst() : bool
Return values
bool

removeTranslation()

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

setActive()

public setActive(bool $active) : $this
Parameters
$active : bool
Return values
$this

setAsset()

public setAsset(TImage|null $asset) : $this
Parameters
$asset : TImage|null
Return values
$this

setAssetPath()

public setAssetPath(string|null $assetPath) : $this
Parameters
$assetPath : string|null
Return values
$this

setForFree()

public setForFree(bool $forFree) : $this
Parameters
$forFree : bool
Return values
$this

setIconClass()

public setIconClass(string|null $iconClass) : $this
Parameters
$iconClass : string|null
Return values
$this

setId()

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

setLevel()

public setLevel(int $level) : $this
Parameters
$level : int
Return values
$this

setLft()

public setLft(int $lft) : $this
Parameters
$lft : int
Return values
$this

setParentId()

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

setPreferred()

public setPreferred(bool $preferred) : $this
Parameters
$preferred : bool
Return values
$this

setRgt()

public setRgt(int $rgt) : $this
Parameters
$rgt : int
Return values
$this

setTopedFirst()

public setTopedFirst(bool $topedFirst) : $this
Parameters
$topedFirst : 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