ToggleRedrawTrait
Shared plumbing for toggle actions (favourite).
FavouriteTrait adds 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.
Methods
- setFavouriteRedrawSnippets() : 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.
private
array<string|int, string>
$favouriteRedrawSnippets
= ['advert']
Default = the whole card.
Methods
setFavouriteRedrawSnippets()
public
setFavouriteRedrawSnippets(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