Repository navigation
v1.2.0
This release adds a way to build content from code, Symfony events around the builder's actions, and several translation features. Everything is additive: existing pages render the same.
Build content from code (klehm/content-blocks)
ContentManipulatorInterface adds, moves, duplicates, deletes and restores sections, columns and blocks the same way the builder does. Use it in fixtures, CMS migrations or seed commands instead of setting positions and ids by hand.
- A new section gets its layout's columns. A new block starts from its type's default data.
- Changes are written to the draft. The service never flushes, and nothing goes live until you publish.
- If a change can't be applied, the service throws
ContentManipulationExceptionwith a stablereasoncode.
The builder's own endpoints now use this service, so decorating it also covers the changes editors make. → Content from code
Server-side events (klehm/content-blocks)
Eight events in ContentBlocks\Event, in before/after pairs, around publish, discard, block save and block delete.
- A
Before…listener can refuse the action with$event->refuse('Why.'). The builder then shows the reason and changes nothing. - The
After…events run after the flush. Use them for a cache purge or a webhook.
Translation (klehm/content-blocks-i18n)
- Publish one language. The workbench has Publish and Discard buttons for the language being translated. They are disabled while the page itself has unpublished changes, because publishing would put those changes live too.
- Replace images and videos per language. The kit's image, gallery, card and video blocks accept a different file for each language. Until one is uploaded, the source file is shown.
- Translations carried by section templates and the clipboard. A translated section keeps its translations when it is saved to the library or copied and pasted.
- Locale fallback chain (opt-in). With
content_blocks_i18n.fallbacks: { fr_CA: fr }, an untranslatedfr_CAfield shows thefrtranslation before falling back to the source. You can also supply the chains from a service by aliasingLocaleFallbacksProviderInterface. - hreflang links.
{{ cb_i18n_hreflang(page.contentArea) }}prints the<link rel="alternate" hreflang>tags, plusx-default.cb_i18n_alternates(area)returns the same data for your own markup. - Empty pages in progress badges.
cb_i18n_progress()gains anemptykey: a page with nothing to translate no longer reads as 100 % translated.
Fixed
- A translation-only change can be published. After translating a field on an already published page, the builder's Publish button stayed disabled.
- The workbench preview showed the source language on Sylius, and on any host that resets the request locale.
- Duplicating a single block lost its translations. Duplicating its whole section already kept them.
- Machine translation shows that it is running, and a run can no longer be started twice.
Upgrading
No database migration. The three packages are tagged together.
composer update "klehm/content-blocks*"klehm/content-blocks-i18nnow requiresklehm/content-blocks^1.2. Before, some translation features were quietly left out on an older core. They are now always on.- Copied
builder/shell.html.twigorlauncher.html.twig? Replacearea.hasUnpublishedChangeswithcb_has_unpublished_changes(area). Otherwise the Publish button won't light up for a translation-only change. - Overriding the
cb-buildercontroller file through your importmap or bundler? Its code is now split into one file per feature underassets/builder/. Override the file that holds the method you need.