ToggleRedrawTrait
Shared plumbing for toggle actions (favourite / follow).
FavouriteTrait and FollowTrait add only handle* methods + their processing; the shared signal finish — remember the rendered style, redraw the component's own snippet and flash messages — lives here.
Per-item AJAX isolation comes from each advert being a separate component instance (Multiplier) — redrawing its single 'advert' snippet is enough.
Table of Contents
Properties
- $selectedStyle : string|null
- $favouriteRedrawSnippets : array<string|int, string>
- Snippets / snippet areas redrawn after an AJAX toggle. Separate for favourite and follow — each action may refresh a different part.
- $followRedrawSnippets : array<string|int, string>
Methods
- setFavouriteRedrawSnippets() : self
- setFollowRedrawSnippets() : self
- finishToggle() : void
- Finishes a toggle signal: sets the style (so the default is not rendered after AJAX), redraws the given snippets of this component and flash messages.
Properties
$selectedStyle
protected
string|null
$selectedStyle
= null
$favouriteRedrawSnippets
Snippets / snippet areas redrawn after an AJAX toggle. Separate for favourite and follow — each action may refresh a different part.
private
array<string|int, string>
$favouriteRedrawSnippets
= ['advert']
Default = the whole card.
$followRedrawSnippets
private
array<string|int, string>
$followRedrawSnippets
= ['advert']
Methods
setFavouriteRedrawSnippets()
public
setFavouriteRedrawSnippets(string ...$snippets) : self
Parameters
- $snippets : string
Return values
selfsetFollowRedrawSnippets()
public
setFollowRedrawSnippets(string ...$snippets) : self
Parameters
- $snippets : string
Return values
selffinishToggle()
Finishes a toggle signal: sets the style (so the default is not rendered after AJAX), redraws the given snippets of this component and flash messages.
private
finishToggle(string $style[, array<string|int, string> $snippets = ['advert'] ]) : void
Parameters
- $style : string
- $snippets : array<string|int, string> = ['advert']
-
snippet / snippet-area names to redraw