diff --git a/app/Classes/MetadataManager.php b/app/Classes/MetadataManager.php index ec31f61..05fac30 100644 --- a/app/Classes/MetadataManager.php +++ b/app/Classes/MetadataManager.php @@ -114,6 +114,14 @@ public function setMany(array $array, bool $replace = false) } } + /** + * Forget any metadata in this file. + */ + public function clear() + { + $this->content = []; + } + public function merge(array $array) { $content = collect($this->content)->dot(); diff --git a/app/Console/Commands/Bundle/DeadLinks.php b/app/Console/Commands/Bundle/DeadLinks.php index 426e278..ec0dfd1 100644 --- a/app/Console/Commands/Bundle/DeadLinks.php +++ b/app/Console/Commands/Bundle/DeadLinks.php @@ -13,7 +13,10 @@ class DeadLinks extends Command * * @var string */ - protected $signature = 'bundle:dead-links { --r|recursive : Also check sub-bundles } { path? : Specific bundle for which to find dead links }'; + protected $signature = 'bundle:dead-links + { --c|clear : Clear current links.json file } + { --r|recursive : Also check sub-bundles } + { path? : Specific bundle for which to find dead links }'; /** * The console command description. @@ -39,6 +42,13 @@ public function handle() foreach ($bundles as $bundle) { $bundle->load(); + if ($this->option('clear')) { + $bundle->metadata('links')->clear(); + $bundle->metadata('links')->save(); + + continue; + } + $deadLinks = []; foreach ($bundle->metadata('links')->all() as $url => $data) { @@ -58,5 +68,11 @@ public function handle() $this->newLine(); } } + + if ($this->option('clear')) { + $this->call('cache:clear'); + $this->comment('links.json file(s) have been removed.'); + $this->line('Remember to re-render bundles to check for dead links.'); + } } }