TemplateWriter final readonly class
Minn\Theme\TemplateWriter · public/minn/src/Minn/Theme/TemplateWriter.php · 116 lines
Saving and removing block templates. A template the theme ships is never touched on disk: editing one writes a wp_template row that shadows the file, and deleting that row is what "reset to the theme version" means.
Constants and properties
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\PostWriter $writer | Promoted from the constructor. |
| private | readonly Minn\Content\Terms $terms | Promoted from the constructor. |
| private | readonly Minn\Content\Site $site | Promoted from the constructor. |
| private | readonly Minn\Theme\TemplateIndex $index | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db, Minn\Content\PostWriter $writer, Minn\Content\Terms $terms, Minn\Content\Site $site, Minn\Theme\TemplateIndex $index)# | ||||
| method | save(Minn\Theme\TemplateRecord $record, array $fields, int $authorId): int# | Writes the site's own copy of a template, creating the row the first time. Returns the post id.
| |||
| method | create(Minn\Theme\TemplateRecord $record, array $fields, int $authorId): int# | A new site copy from the collection's create: as a save inserts one, but recording no origin, even over a theme file (probe rest-template-create).
| |||
| method | trash(Minn\Theme\TemplateRecord $record): void# | Moves a site copy to the trash, which hands the theme's file back. | |||
| method | destroy(Minn\Theme\TemplateRecord $record): void# | Deletes a saved template row. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.