Skip to content

v1.2.0

Choose a tag to compare

@Klehm Klehm released this 29 Sep 11:33
· 113 commits to master since this release
269b266

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 ContentManipulationException with a stable reason code.

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.

→ Server-side events

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 untranslated fr_CA field shows the fr translation before falling back to the source. You can also supply the chains from a service by aliasing LocaleFallbacksProviderInterface.
  • hreflang links. {{ cb_i18n_hreflang(page.contentArea) }} prints the <link rel="alternate" hreflang> tags, plus x-default. cb_i18n_alternates(area) returns the same data for your own markup.
  • Empty pages in progress badges. cb_i18n_progress() gains an empty key: a page with nothing to translate no longer reads as 100 % translated.

→ Translation guide

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-i18n now requires klehm/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.twig or launcher.html.twig? Replace area.hasUnpublishedChanges with cb_has_unpublished_changes(area). Otherwise the Publish button won't light up for a translation-only change.
  • Overriding the cb-builder controller file through your importmap or bundler? Its code is now split into one file per feature under assets/builder/. Override the file that holds the method you need.

Details in each package's changelog: core · kit · i18n