Component Sync
Automatic Sync
Added in
21torr/storyblok v5.3The Storyblok bundle integrates natively with the hosting bundle and offers an automatic sync when doing an app deployment:
bin/console hosting:hook:deploy-app
Before it actually syncs the components to Storyblok however, you need to enable the environments where the automatic sync is enabled:
conf/packages/storyblok.yaml
storyblok:
sync_definitions_on_app_deploy:
staging: false
production: true
With this config the automatic sync is only enabled when deploying the app on production.1
Manual Sync
You can also manually sync the components using the CLI:
bin/console storyblok:definitions:sync
Definitions Synced Event
After a successful storyblok:definitions:sync, the bundle dispatches StoryblokDefinitionsSyncedEvent.
Event Data
The event provides:
io:TorrStyleinstance used by the sync command.adapter: the adapter that was synced.
Listener Example
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Torr\Storyblok\Event\StoryblokDefinitionsSyncedEvent;
#[AsEventListener]
public function onDefinitionsSynced (StoryblokDefinitionsSyncedEvent $event) : void
{
$event->io->writeln("Run post-sync work...");
$event->adapter->managementApi;
}
Notes
- If multiple adapters are synced in one command run, one event is dispatched per adapter.
- The event is only dispatched on successful sync.