From 50c647b158754d8bf3c2c02fe2f0b7b7be609a62 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 27 Feb 2024 09:24:15 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Do=20not=20?= =?UTF-8?q?retrieve=20the=20existing=20cache=20when=20recaching=20(#203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🧑‍💻 Add block construct replacements to `acf:upgrade` --- src/AcfComposer.php | 2 +- src/Composer.php | 6 +++--- src/Console/UpgradeCommand.php | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AcfComposer.php b/src/AcfComposer.php index a48d57fb..a2b9be98 100644 --- a/src/AcfComposer.php +++ b/src/AcfComposer.php @@ -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( diff --git a/src/Composer.php b/src/Composer.php index dce9b8e2..98b3e78f 100644 --- a/src/Composer.php +++ b/src/Composer.php @@ -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); } diff --git a/src/Console/UpgradeCommand.php b/src/Console/UpgradeCommand.php index a578a93c..6b65db34 100644 --- a/src/Console/UpgradeCommand.php +++ b/src/Console/UpgradeCommand.php @@ -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]})", ];