We try to keep our fieldsets organised. For a pagebuilder(Bard field) with a lot of blocks and includes it can get messy fast.
The idea was to create a local addon to use as a container for the pagebuilder resources (fieldsets, views, etc).
In the development of the site we change the pagebuilder quite a lot and notice that it's saved in the overridden folder in de resources/fieldsets/vendor folder. We want is saved in the addon resources/fieldsets.
In the Statamic\Fields\FieldsetRepository::save function there is a if statement that checks if the fieldset isNamespaced. Then save puts the fieldset file in the /vendor/ folder in the resources/fieldsets. It would be great if the save method checks if the fieldset is in a local addon and saved it there.
The current save method is:
public function save(Fieldset $fieldset)
{
$directory = $this->directory;
if ($fieldset->isNamespaced()) {
[$key, $handle] = explode('::', $fieldset->handle());
$directory = $this->directory.'/vendor/'.$key;
}
$handle = Str::of($fieldset->handle())->after('::')->replace('.', '/');
File::put(
"{$directory}/{$handle}.yaml",
YAML::dump($fieldset->contents())
);
}
My suggestion is to check if the fieldsets path starts with the base_path('addons') and if so then save it at the fieldset in the local addon resources/fieldsets path. Maybe the save function can look something like this:
We try to keep our fieldsets organised. For a pagebuilder(Bard field) with a lot of blocks and includes it can get messy fast.
The idea was to create a local addon to use as a container for the pagebuilder resources (fieldsets, views, etc).
In the development of the site we change the pagebuilder quite a lot and notice that it's saved in the overridden folder in de
resources/fieldsets/vendor
folder. We want is saved in the addonresources/fieldsets
.In the
Statamic\Fields\FieldsetRepository::save
function there is a if statement that checks if the fieldsetisNamespaced
. Then save puts the fieldset file in the/vendor/
folder in theresources/fieldsets
. It would be great if the save method checks if the fieldset is in a local addon and saved it there.The current save method is:
My suggestion is to check if the fieldsets path starts with the
base_path('addons')
and if so then save it at the fieldset in the local addonresources/fieldsets
path. Maybe the save function can look something like this:Love to hear your thoughts about this.