This is an old revision of the document!
Table of Contents
SidebarViewModel
Layer: Core · Source: lib/core/Theme/SidebarViewModel.php:19 (lines 19–178)
final class SidebarViewModel extends AbstractThemeViewModel
Sidebar view model.
Carries the already-escaped aggregates the sidebar template renders: latest posts, categories, archives and tags. Every nested value is escaped once at construction time.
Docblock Metadata
^ Tag ^ Value ^ | ''@category'' | Theme | | ''@author'' | M.Noermoehammad | | ''@license'' | MIT | | ''@version'' | 1.0 |
Inheritance
^ Relation ^ Type ^ Meaning ^ | extends | [[scriptlog:lib:core:abstractthemeviewmodel|''AbstractThemeViewModel'']] | parent class/interface |
Constants (0)
None.
Properties (4)
^ Visibility ^ Type ^ Name ^ Default ^ Line ^ | ''private'' | ''(untyped)'' | ''$latestPosts'' | ''[];'' | 22 | | ''private'' | ''(untyped)'' | ''$categories'' | ''[];'' | 25 | | ''private'' | ''(untyped)'' | ''$archives'' | ''[];'' | 28 | | ''private'' | ''(untyped)'' | ''$tags'' | ''[];'' | 31 |
Methods (7)
^ Visibility ^ Method ^ Summary ^ Line ^
| public static | ''fromRow()'' | Build a sidebar view model. | 40 |
| public static | ''fromPrepared()'' | Build a sidebar view model from already-prepared, already-safe values. | 99 |
| public | ''latestPosts()'' | PostViewModel[] | 132 |
| public | ''categories()'' | array<int, array{title:string|null,url:string,count:string|null}> | 143 |
| public | ''archives()'' | array<int, array{label:string|null,url:string,count:string|null}> | 154 |
| public | ''tags()'' | array<int, array{label:string|null,url:string}> | 165 |
| public | ''searchAction()'' | | 174 |
fromRow()
public static function fromRow(array $row, callable $escape)
lines 40–84 (45)
Build a sidebar view model.
^ Parameter ^ Type ^ Default ^ Description ^ | ''$row'' | ''array'' | //required// | //none// | | ''$escape'' | ''callable'' | //required// | //none// |
Returns: (none declared) — static
fromPrepared()
public static function fromPrepared(array $prepared)
lines 99–124 (26)
Build a sidebar view model from already-prepared, already-safe values.
Mirrors PostViewModel::fromPrepared(): nested values are escaped or normalized exactly once at the boundary (prepare_sidebar()) and stored verbatim. latest_posts must be an array of PostViewModel instances.
^ Parameter ^ Type ^ Default ^ Description ^ | ''$prepared'' | ''array'' | //required// | //none// |
Returns: (none declared) — static
latestPosts()
public function latestPosts(): array
lines 132–135 (4)
Takes no parameters.
Returns: array — PostViewModel[]
categories()
public function categories(): array
lines 143–146 (4)
Takes no parameters.
Returns: array — array<int, array{title:string|null,url:string,count:string|null}>
archives()
public function archives(): array
lines 154–157 (4)
Takes no parameters.
Returns: array — array<int, array{label:string|null,url:string,count:string|null}>
tags()
public function tags(): array
lines 165–168 (4)
Takes no parameters.
Returns: array — array<int, array{label:string|null,url:string}>
searchAction()
public function searchAction(): string
lines 174–177 (4)
Takes no parameters.
Returns: string
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
