statamic / ideas

💡Discussions on ideas and feature requests for Statamic
https://statamic.dev
32 stars 1 forks source link

Register/enable/disable bard sets via PHP #1244

Open godismyjudge95 opened 4 weeks ago

godismyjudge95 commented 4 weeks ago

I looked through the docs but did not find anything. It would be great if you could register/enable/disable bard sets via PHP.

Something like:

Bard::registerSet(name: 'testimonials-v2', group: 'blocks', set: [
    'display' => 'Testimonials',
    'icon' => 'text-formatting-quotation',
    'fields' => ['import' => 'block_testimonials'],
]);

And if you needed to register it based on a specific condition:

Bard::boot(function ($field, $context) {
    if ($context['collection'] === 'posts') {
        return;
    }

    register_custom_sets();
});

Finally to disable a set:

Bard::deregisterSet('testimonials-v1');