CoolCMS API

MessageInfoLine extends BaseComponent
in package
uses InitTrait, VoteTrait, FavouriteHandlerTrait

Table of Contents

Properties

$container  : Container
$routerDispatcher  : RouterDispatcher
$translator  : ITranslator
$appContext  : AppContext
$componentParameters  : array<string, mixed>
$currencyContext  : CurrencyContext|null
$deviceDetector  : DeviceDetector|null
$languageContext  : LanguageContext|null
$localizationContext  : LocalizationContext|null
$settingContext  : SettingContext
$themeContext  : ThemeContext|null
$translatorDomain  : string|null
$favouriteSessionSection  : string
$favouriteSnippets  : array<int, string>
$message  : Message|null
$messageManager  : MessageManager
$messageReportManager  : MessageReportManager
$messageVoteManager  : MessageVoteManager
$profile  : PublicProfile|null
$ratingFactory  : RatingFactory
$recommendFormFactory  : RecommendFormFactory
$selectedStyle  : string|null
$session  : Session
$thumbs  : array<int, string>
Which rating thumbs to show (`['up','down']`, `['up']` or `['down']`).

Methods

__call()  : mixed
Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
__construct()  : mixed
addFavouriteSnippets()  : void
createComponent()  : IComponent|null
createComponentRating()  : Rating
Like / dislike voting through the unified `RatingComponent` (Thumbs style).
createComponentRecommendForm()  : RecommendForm
getAppContext()  : AppContext
getComponentParameter()  : mixed
Returns a component parameter, or null when it is not set.
getContainer()  : Container
getCurrencyContext()  : CurrencyContext|null
getFavouriteSnippets()  : array<int, string>
getLanguageContext()  : LanguageContext|null
getLocalizationContext()  : LocalizationContext|null
getMessage()  : Message|null
getProfile()  : PublicProfile|null
getRouterDispatcher()  : RouterDispatcher
getSettingContext()  : SettingContext
getSettings()  : array<int, array<string, mixed>>
getThemeContext()  : ThemeContext|null
handleAddToFavourites()  : void
handleDelFromFavourites()  : void
handleReport()  : void
Writes to the DB; AJAX only. A bare GET (robot, link prefetch) ends with 403.
handleThumbsDown()  : void
Writes to the DB; AJAX only. A bare GET (robot, link prefetch) ends with 403.
handleThumbsUp()  : void
Writes to the DB; AJAX only. A bare GET (robot, link prefetch) ends with 403.
hasServiceByType()  : bool
Returns whether the container has a service of the given type.
initFavourites()  : void
initializeAllContexts()  : void
injectDeviceDetector()  : void
onCreate()  : void
render()  : void
renderStyle2()  : void
renderStyle3()  : void
setAppContext()  : $this
setComponentParameter()  : void
Sets a component parameter.
setCurrencyContext()  : $this
setFavouritesForTemplate()  : void
setFavouriteSnippets()  : void
setLanguageContext()  : $this
setLocalizationContext()  : $this
setMessage()  : self
setProfile()  : self
setSettingContext()  : $this
setThemeContext()  : $this
setThumbs()  : self
Limits the displayed rating thumbs, e.g. `['up']` shows only "like".
setup()  : void
setupAppContext()  : void
typedComponent()  : T
Returns a subcomponent with a verified type.
frontPresenter()  : BasePresenter|null
Returns the front presenter the component is attached to (null outside the front end or when detached).
getFavouriteIds()  : array<int, int>
getFavouriteSessionStorage()  : Session
getTranslator()  : ITranslator
setTemplateFile()  : void
setTranslator()  : self
bumpDisplayedVotes()  : void
Raises the counter on the displayed in-memory entity after a successful vote, without a DB read.
createMultiplierComponent()  : Multiplier<string|int, IComponent>
Creates a multiplier for the component.
createNewComponentInstance()  : IComponent|null
Creates a new component instance without adding it to the presenter; used by the multiplier.
createStandardComponent()  : IComponent|null
Creates a standard component (not a multiplier).
getFavouriteSection()  : SessionSection
isEntityInFavourites()  : bool

Properties

$componentParameters

protected array<string, mixed> $componentParameters = []

component parameters set by setComponentParameter()

$translatorDomain

protected string|null $translatorDomain = 'front.discussion.components.messageInfoLine'

$favouriteSnippets

private array<int, string> $favouriteSnippets = ['favouriteLinksSnippet', 'flashMessagesSnippet']

$thumbs

Which rating thumbs to show (`['up','down']`, `['up']` or `['down']`).

private array<int, string> $thumbs = ['up', 'down']

Methods

__call()

Dispatches `renderXyz()` to `render('Xyz', ...$args)`.

public __call(string $name, array<string|int, mixed> $args) : mixed

Called only when the component has no renderXyz() method of its own.

Parameters
$name : string
$args : array<string|int, mixed>

__construct()

public __construct(MessageManager $messageManager, MessageVoteManager $messageVoteManager, MessageReportManager $messageReportManager, Session $session, RecommendFormFactory $recommendFormFactory, RatingFactory $ratingFactory) : mixed
Parameters
$messageManager : MessageManager
$messageVoteManager : MessageVoteManager
$messageReportManager : MessageReportManager
$session : Session
$recommendFormFactory : RecommendFormFactory
$ratingFactory : RatingFactory

addFavouriteSnippets()

public addFavouriteSnippets(array<int, string> $snippets) : void
Parameters
$snippets : array<int, string>

createComponent()

public createComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

createComponentRating()

Like / dislike voting through the unified `RatingComponent` (Thumbs style).

public createComponentRating() : Rating

The thread holds the post (ratingThreadId); an anonymous vote follows the module setting voteOnlyForLoggedIn. $this->thumbs decides which thumbs are shown (each thumb renders as a separate <li>).

Return values
Rating

getComponentParameter()

Returns a component parameter, or null when it is not set.

public getComponentParameter(string $name) : mixed
Parameters
$name : string

getContainer()

public getContainer() : Container
Return values
Container

getFavouriteSnippets()

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

getSettings()

public getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

handleAddToFavourites()

public handleAddToFavourites(int $entityId[, string $style = 'Style_1' ]) : void
Parameters
$entityId : int
$style : string = 'Style_1'

handleDelFromFavourites()

public handleDelFromFavourites(int $entityId[, string $style = 'Style_1' ]) : void
Parameters
$entityId : int
$style : string = 'Style_1'

handleReport()

Writes to the DB; AJAX only. A bare GET (robot, link prefetch) ends with 403.

public handleReport(int $messageId[, string $style = 'Style_1' ]) : void
Parameters
$messageId : int
$style : string = 'Style_1'
Attributes
#[Requires]
$ajax: true

handleThumbsDown()

Writes to the DB; AJAX only. A bare GET (robot, link prefetch) ends with 403.

public handleThumbsDown(int $messageId[, string $style = 'Style_1' ]) : void
Parameters
$messageId : int
$style : string = 'Style_1'
Attributes
#[Requires]
$ajax: true

handleThumbsUp()

Writes to the DB; AJAX only. A bare GET (robot, link prefetch) ends with 403.

public handleThumbsUp(int $messageId[, string $style = 'Style_1' ]) : void
Parameters
$messageId : int
$style : string = 'Style_1'
Attributes
#[Requires]
$ajax: true

hasServiceByType()

Returns whether the container has a service of the given type.

public hasServiceByType(string $className) : bool

The name is composed dynamically (module plus component), so class_exists() runs first, and a true result guarantees a valid type.

Parameters
$className : string
Tags
phpstan-assert-if-true

class-string $className

Return values
bool

initFavourites()

public initFavourites(string $sessionSection) : void
Parameters
$sessionSection : string

render()

public render([string $style = 'Style_1' ]) : void
Parameters
$style : string = 'Style_1'

setComponentParameter()

Sets a component parameter.

public setComponentParameter(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

setFavouritesForTemplate()

public setFavouritesForTemplate(int $id) : void
Parameters
$id : int

setFavouriteSnippets()

public setFavouriteSnippets(array<int, string> $snippets) : void
Parameters
$snippets : array<int, string>

setMessage()

public setMessage(Message|null $message) : self
Parameters
$message : Message|null
Return values
self

setThumbs()

Limits the displayed rating thumbs, e.g. `['up']` shows only "like".

public setThumbs(array<int, string> $thumbs) : self
Parameters
$thumbs : array<int, string>
Return values
self

typedComponent()

Returns a subcomponent with a verified type.

public typedComponent(string $name, T> $type) : T

Use it instead of an inline @var above $this['x'] (which does not narrow the type) and instead of the generic IComponent that $this['x'] returns. See Form::typedComponent().

Parameters
$name : string
$type : T>
Tags
template
Return values
T

frontPresenter()

Returns the front presenter the component is attached to (null outside the front end or when detached).

protected frontPresenter() : BasePresenter|null
Return values
BasePresenter|null

getFavouriteIds()

protected getFavouriteIds() : array<int, int>
Return values
array<int, int>

getFavouriteSessionStorage()

protected getFavouriteSessionStorage() : Session
Return values
Session

getTranslator()

protected getTranslator() : ITranslator
Return values
ITranslator

setTemplateFile()

protected setTemplateFile(string $dir, string $filename) : void
Parameters
$dir : string
$filename : string

setTranslator()

protected setTranslator(ITranslator $translator) : self
Parameters
$translator : ITranslator
Return values
self

bumpDisplayedVotes()

Raises the counter on the displayed in-memory entity after a successful vote, without a DB read.

private bumpDisplayedVotes(Message $message, int $messageId, string $property) : void

votesUp / votesDown do not invalidate the query cache (MessageManager::$nonInvalidatingColumns), so the component entity (loaded before the vote) would otherwise show a value one lower. A duplicate vote never gets here (called only on the success branch). Only the message of this component is raised: the id from the URL must match.

Parameters
$message : Message
$messageId : int
$property : string

createMultiplierComponent()

Creates a multiplier for the component.

private createMultiplierComponent(string $name) : Multiplier<string|int, IComponent>
Parameters
$name : string
Return values
Multiplier<string|int, IComponent>

createNewComponentInstance()

Creates a new component instance without adding it to the presenter; used by the multiplier.

private createNewComponentInstance(string $baseName[, int|string|null $uniqueKey = null ]) : IComponent|null
Parameters
$baseName : string
$uniqueKey : int|string|null = null
Return values
IComponent|null

createStandardComponent()

Creates a standard component (not a multiplier).

private createStandardComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

getFavouriteSection()

private getFavouriteSection() : SessionSection
Return values
SessionSection

isEntityInFavourites()

private isEntityInFavourites(int $entityId) : bool
Parameters
$entityId : int
Return values
bool
On this page

Search results