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
$container
public
Container
$container
Attributes
- #[Inject]
$routerDispatcher
public
RouterDispatcher
$routerDispatcher
$translator
public
ITranslator
$translator
Tags
$appContext
protected
AppContext
$appContext
$componentParameters
protected
array<string, mixed>
$componentParameters
= []
component parameters set by setComponentParameter()
$currencyContext
protected
CurrencyContext|null
$currencyContext
= NULL
$deviceDetector
protected
DeviceDetector|null
$deviceDetector
= NULL
$languageContext
protected
LanguageContext|null
$languageContext
= NULL
$localizationContext
protected
LocalizationContext|null
$localizationContext
= NULL
$settingContext
protected
SettingContext
$settingContext
$themeContext
protected
ThemeContext|null
$themeContext
= NULL
$translatorDomain
protected
string|null
$translatorDomain
= 'front.discussion.components.messageInfoLine'
$favouriteSessionSection
private
string
$favouriteSessionSection
$favouriteSnippets
private
array<int, string>
$favouriteSnippets
= ['favouriteLinksSnippet', 'flashMessagesSnippet']
$message
private
Message|null
$message
= null
$messageManager read-only
private
MessageManager
$messageManager
$messageReportManager read-only
private
MessageReportManager
$messageReportManager
$messageVoteManager read-only
private
MessageVoteManager
$messageVoteManager
$profile
private
PublicProfile|null
$profile
= null
$ratingFactory read-only
private
RatingFactory
$ratingFactory
$recommendFormFactory read-only
private
RecommendFormFactory
$recommendFormFactory
$selectedStyle
private
string|null
$selectedStyle
= null
$session read-only
private
Session
$session
$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|nullcreateComponentRating()
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
RatingcreateComponentRecommendForm()
public
createComponentRecommendForm() : RecommendForm
Return values
RecommendFormgetAppContext()
public
getAppContext() : AppContext
Return values
AppContextgetComponentParameter()
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
ContainergetCurrencyContext()
public
getCurrencyContext() : CurrencyContext|null
Return values
CurrencyContext|nullgetFavouriteSnippets()
public
getFavouriteSnippets() : array<int, string>
Return values
array<int, string>getLanguageContext()
public
getLanguageContext() : LanguageContext|null
Return values
LanguageContext|nullgetLocalizationContext()
public
getLocalizationContext() : LocalizationContext|null
Return values
LocalizationContext|nullgetMessage()
public
getMessage() : Message|null
Return values
Message|nullgetProfile()
public
getProfile() : PublicProfile|null
Return values
PublicProfile|nullgetRouterDispatcher()
public
getRouterDispatcher() : RouterDispatcher
Return values
RouterDispatchergetSettingContext()
public
getSettingContext() : SettingContext
Return values
SettingContextgetSettings()
public
getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>getThemeContext()
public
getThemeContext() : ThemeContext|null
Return values
ThemeContext|nullhandleAddToFavourites()
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
Return values
boolinitFavourites()
public
initFavourites(string $sessionSection) : void
Parameters
- $sessionSection : string
initializeAllContexts()
public
initializeAllContexts() : void
injectDeviceDetector()
public
injectDeviceDetector(DeviceDetector $detector) : void
Parameters
- $detector : DeviceDetector
onCreate()
public
onCreate() : void
render()
public
render([string $style = 'Style_1' ]) : void
Parameters
- $style : string = 'Style_1'
renderStyle2()
public
renderStyle2() : void
renderStyle3()
public
renderStyle3() : void
setAppContext()
public
setAppContext(AppContext $appContext) : $this
Parameters
- $appContext : AppContext
Return values
$thissetComponentParameter()
Sets a component parameter.
public
setComponentParameter(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setCurrencyContext()
public
setCurrencyContext(CurrencyContext|null $currencyContext) : $this
Parameters
- $currencyContext : CurrencyContext|null
Return values
$thissetFavouritesForTemplate()
public
setFavouritesForTemplate(int $id) : void
Parameters
- $id : int
setFavouriteSnippets()
public
setFavouriteSnippets(array<int, string> $snippets) : void
Parameters
- $snippets : array<int, string>
setLanguageContext()
public
setLanguageContext(LanguageContext|null $languageContext) : $this
Parameters
- $languageContext : LanguageContext|null
Return values
$thissetLocalizationContext()
public
setLocalizationContext(LocalizationContext|null $localizationContext) : $this
Parameters
- $localizationContext : LocalizationContext|null
Return values
$thissetMessage()
public
setMessage(Message|null $message) : self
Parameters
- $message : Message|null
Return values
selfsetProfile()
public
setProfile(PublicProfile|null $profile) : self
Parameters
- $profile : PublicProfile|null
Return values
selfsetSettingContext()
public
setSettingContext(SettingContext $settingContext) : $this
Parameters
- $settingContext : SettingContext
Return values
$thissetThemeContext()
public
setThemeContext(ThemeContext|null $themeContext) : $this
Parameters
- $themeContext : ThemeContext|null
Return values
$thissetThumbs()
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
selfsetup()
public
setup(BasePresenter|BasePresenter $presenter) : void
Parameters
- $presenter : BasePresenter|BasePresenter
setupAppContext()
public
setupAppContext(AppContext $appContext) : void
Parameters
- $appContext : AppContext
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
Return values
TfrontPresenter()
Returns the front presenter the component is attached to (null outside the front end or when detached).
protected
frontPresenter() : BasePresenter|null
Return values
BasePresenter|nullgetFavouriteIds()
protected
getFavouriteIds() : array<int, int>
Return values
array<int, int>getFavouriteSessionStorage()
protected
getFavouriteSessionStorage() : Session
Return values
SessiongetTranslator()
protected
getTranslator() : ITranslator
Return values
ITranslatorsetTemplateFile()
protected
setTemplateFile(string $dir, string $filename) : void
Parameters
- $dir : string
- $filename : string
setTranslator()
protected
setTranslator(ITranslator $translator) : self
Parameters
- $translator : ITranslator
Return values
selfbumpDisplayedVotes()
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|nullcreateStandardComponent()
Creates a standard component (not a multiplier).
private
createStandardComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullgetFavouriteSection()
private
getFavouriteSection() : SessionSection
Return values
SessionSectionisEntityInFavourites()
private
isEntityInFavourites(int $entityId) : bool
Parameters
- $entityId : int