CoolCMS API

News extends News
in package

Admin variant of a news item (`cms_mod_blog_news`), hydrated from the `api/blog/news` endpoint.

The admin presenter edits translations, scalar fields (publication, activation) and the region (region, to-one via a Picker). Author, image and categories are not edited here and exist only as scalar FKs from the parent; their associations are not mapped, so the admin save does not touch foreign links (extract sends only mapped properties).

Tags
extends
Attributes
#[Entity]
#[Table]
$name: 'cms_mod_blog_news'
#[TableAlias]
'news'

Table of Contents

Properties

$active  : bool
$asset  : TImage|null
$author  : string|null
$categories  : Collection<int, TCategory>
$id  : int|null
$insertTime  : DateTime
$published  : DateTime|null
$region  : object|null
$regionId  : int|null
$translations  : Collection<int, NewsText>
$user  : TUser|null
$userId  : int|null

Methods

__construct()  : mixed
addCategory()  : $this
addTranslation()  : $this
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
categoryCollectionInit()  : void
clearCategories()  : $this
getActive()  : bool
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getAsset()  : TImage|null
getAuthor()  : string|null
getCategories()  : Collection<int, TCategory>
getCategoryIds()  : array<string|int, int>
getFirstCategoryId()  : int|null
getId()  : int|null
getInsertTime()  : DateTime
getPublished()  : DateTime|null
getRegion()  : object|null
getRegionId()  : int|null
getTranslation()  : TTranslation|null
getTranslations()  : Collection<int, TTranslation>
getUser()  : TUser|null
getUserId()  : int|null
isActive()  : bool
isPersisted()  : bool
isPubliclyVisible()  : bool
Whether the detail is public: active and published today or earlier (day granularity, same rule as the list).
removeCategory()  : $this
removeTranslation()  : $this
setActive()  : $this
setAsset()  : $this
setAuthor()  : $this
setCategories()  : $this
setId()  : $this
setInsertTime()  : $this
setPublished()  : $this
setRegion()  : $this
setRegionId()  : $this
setTranslations()  : $this
setUser()  : $this
setUserId()  : $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: 'activated'
$type: 'boolean'

$author

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

$categories

protected Collection<int, TCategory> $categories = new ArrayCollection()
Attributes
#[Transient]

$id

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

$insertTime

protected DateTime $insertTime = new DateTime()
Attributes
#[Column]
$name: 'insert_time'
$type: 'datetime'
#[ExternalReadonly]

$published

protected DateTime|null $published = null
Attributes
#[Column]
$name: 'published'
$type: 'datetime'
$nullable: true

$region

protected object|null $region = null
Attributes
#[EntityOf]
\App\UI\Admin\System\Models\Entities\Region::class
#[JoinColumn]
$name: 'cms_system_regions_region_id'
$referencedColumnName: 'region_id'
$nullable: true
$onDelete: 'SET NULL'
#[ManyToOne]
$targetEntity: \App\UI\Admin\System\Models\Entities\Region::class
$fetch: "LAZY"

$regionId

protected int|null $regionId = null
Attributes
#[Column]
$name: 'cms_system_regions_region_id'
$type: 'integer'
$nullable: true
$insertable: false
$updatable: false
$options: ['unsigned' => true]

$translations

protected Collection<int, NewsText> $translations
Attributes
#[CollectionOf]
\App\UI\Admin\Blog\Models\Entities\NewsText::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Admin\Blog\Models\Entities\NewsText::class
$mappedBy: 'parent'
$cascade: ["persist", "remove"]
$orphanRemoval: true
$fetch: "LAZY"

$userId

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

Methods

__construct()

public __construct([int|null $id = null ][, DateTime $insertTime = new DateTime() ][, DateTime|null $published = null ][, bool $active = true ][, string|null $author = null ][, int|null $userId = null ][, int|null $regionId = null ][, mixed $user = null ][, mixed $region = null ][, mixed $asset = null ][, Collection $translations = new ArrayCollection() ][, Collection $categories = new ArrayCollection() ]) : mixed
Parameters
$id : int|null = null
$insertTime : DateTime = new DateTime()
$published : DateTime|null = null
$active : bool = true
$author : string|null = null
$userId : int|null = null
$regionId : int|null = null
$user : mixed = null
$region : mixed = null
$asset : mixed = null
$translations : Collection = new ArrayCollection()
$categories : Collection = new ArrayCollection()

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

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

getAuthor()

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

getCategories()

public getCategories() : Collection<int, TCategory>
Return values
Collection<int, TCategory>

getCategoryIds()

public getCategoryIds() : array<string|int, int>
Return values
array<string|int, int>

getInsertTime()

public getInsertTime() : DateTime
Return values
DateTime

getPublished()

public getPublished() : DateTime|null
Return values
DateTime|null

getRegion()

public getRegion() : object|null
Return values
object|null

getRegionId()

public getRegionId() : int|null
Return values
int|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>

getUser()

public getUser() : TUser|null
Return values
TUser|null

getUserId()

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

isActive()

public isActive() : bool
Return values
bool

isPubliclyVisible()

Whether the detail is public: active and published today or earlier (day granularity, same rule as the list).

public isPubliclyVisible([DateTimeInterface|null $now = null ]) : bool
Parameters
$now : DateTimeInterface|null = null
Return values
bool

removeCategory()

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

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

setAuthor()

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

setId()

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

setInsertTime()

public setInsertTime(DateTime $insertTime) : $this
Parameters
$insertTime : DateTime
Return values
$this

setPublished()

public setPublished(DateTime|null $published) : $this
Parameters
$published : DateTime|null
Return values
$this

setRegion()

public setRegion(object|null $region) : $this
Parameters
$region : object|null
Return values
$this

setRegionId()

public setRegionId(int|null $regionId) : $this
Parameters
$regionId : int|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

setUser()

public setUser(TUser|null $user) : $this
Parameters
$user : TUser|null
Return values
$this

setUserId()

public setUserId(int|null $userId) : $this
Parameters
$userId : int|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