Skip to content

Commit

Permalink
First run of script
Browse files Browse the repository at this point in the history
  • Loading branch information
robdekort committed Nov 4, 2021
1 parent c67377c commit b435897
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions dev/app/Console/Commands/AddSet.php
Expand Up @@ -55,7 +55,7 @@ public function handle()

try {
$this->checkExistence('Fieldset', "resources/fieldsets/{$this->filename}.yaml");
$this->checkExistence('Partial', "resources/views/page_builder/_{$this->filename}.antlers.html");
$this->checkExistence('Partial', "resources/views/components/_{$this->filename}.antlers.html");

$this->createFieldset();
$this->createPartial();
Expand All @@ -64,7 +64,7 @@ public function handle()
return $this->error($e->getMessage());
}

$this->info("Peak page builder block '{$this->block_name}' added.");
$this->info("Peak page builder Article set '{$this->set_name}' added.");
}

/**
Expand All @@ -88,7 +88,7 @@ protected function createFieldset()
{
$stub = File::get(__DIR__.'/stubs/fieldset_set.yaml.stub');
$contents = Str::of($stub)
->replace('{{ name }}', $this->block_name);
->replace('{{ name }}', $this->set_name);

File::put(base_path("resources/fieldsets/{$this->filename}.yaml"), $contents);
}
Expand All @@ -100,12 +100,12 @@ protected function createFieldset()
*/
protected function createPartial()
{
$stub = File::get(__DIR__.'/stubs/block.html.stub');
$stub = File::get(__DIR__.'/stubs/set.html.stub');
$contents = Str::of($stub)
->replace('{{ name }}', $this->block_name)
->replace('{{ name }}', $this->set_name)
->replace('{{ filename }}', $this->filename);

File::put(base_path("resources/views/page_builder/_{$this->filename}.antlers.html"), $contents);
File::put(base_path("resources/views/components/_{$this->filename}.antlers.html"), $contents);
}

/**
Expand All @@ -115,10 +115,9 @@ protected function createPartial()
*/
protected function updatePageBuilder()
{
$fieldset = Yaml::parseFile(base_path('resources/fieldsets/page_builder.yaml'));
$fieldset = Yaml::parseFile(base_path('resources/fieldsets/article.yaml'));
$newSet = [
'display' => $this->block_name,
'instructions' => $this->instructions,
'display' => $this->set_name,
'fields' => [
[
'import' => $this->filename
Expand All @@ -134,6 +133,6 @@ protected function updatePageBuilder()

Arr::set($fieldset, 'fields.0.field.sets', $existingSets);

File::put(base_path('resources/fieldsets/page_builder.yaml'), Yaml::dump($fieldset, 99, 2));
File::put(base_path('resources/fieldsets/article.yaml'), Yaml::dump($fieldset, 99, 2));
}
}
2 changes: 1 addition & 1 deletion dev/app/Console/Commands/stubs/fieldset_set.yaml.stub
Expand Up @@ -4,4 +4,4 @@ fields:
handle: size
field: common.size
config:
instructions: 'The size in which the quote should be displayed.'
instructions: 'The size in which the {{ name }} should be displayed.'

0 comments on commit b435897

Please sign in to comment.