Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Do not retrieve the existing cache when recaching (#203)
Browse files Browse the repository at this point in the history
* πŸ§‘β€πŸ’» Add block construct replacements to `acf:upgrade`
  • Loading branch information
Log1x authored Feb 27, 2024
1 parent 24e7eac commit 50c647b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AcfComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function manifestExists(): bool
public function cache(Composer $composer): bool
{
$manifest = $this->manifest()
->put($composer::class, $composer->getFields())
->put($composer::class, $composer->getFields(cache: false))
->all();

return file_put_contents(
Expand Down
6 changes: 3 additions & 3 deletions src/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ protected function register(?callable $callback = null): void
/**
* Retrieve the field group fields.
*/
public function getFields(): array
public function getFields(bool $cache = true): array
{
if ($this->fields) {
if ($this->fields && $cache) {
return $this->fields;
}

if ($this->composer->hasCache($this)) {
if ($cache && $this->composer->hasCache($this)) {
return $this->composer->getCache($this);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Console/UpgradeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public function handle()

$this->replacements = [
'use StoutLogic\\AcfBuilder\\FieldsBuilder;' => 'use Log1x\\AcfComposer\\Builder;',
'use Roots\\Acorn\\Application;' => 'use Log1x\\AcfComposer\\AcfComposer;',
'new FieldsBuilder(' => 'Builder::make(',
'public function enqueue($block)' => 'public function assets($block)',
'public function enqueue($block = [])' => 'public function assets($block)',
'public function enqueue()' => 'public function assets($block)',
'public function __construct(Application $app)' => 'public function __construct(AcfComposer $composer)',
'/->addFields\(\$this->get\((.*?)\)\)/' => fn ($match) => "->addPartial({$match[1]})",
];

Expand Down

0 comments on commit 50c647b

Please sign in to comment.