From 0d34c92442459cb7141d137e13fc896178696c90 Mon Sep 17 00:00:00 2001 From: Andrew Feeney Date: Mon, 4 Sep 2017 19:25:53 +1000 Subject: [PATCH 1/2] WIP --- src/Arc/Console/LinkPluginCommand.php | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/Arc/Console/LinkPluginCommand.php diff --git a/src/Arc/Console/LinkPluginCommand.php b/src/Arc/Console/LinkPluginCommand.php new file mode 100644 index 0000000..aedc508 --- /dev/null +++ b/src/Arc/Console/LinkPluginCommand.php @@ -0,0 +1,62 @@ +app = $app; + $this->fileManager = $this->app->make(FileManager::class); + + parent::__construct(); + } + + /** + * The console command name. + * + * @var string + */ + protected $signature = 'link {wordpressPath} {--f}'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Install the plugin into local wordpress instance by symlink'; + + /** + * Execute the console command. + * + * @return bool|null + */ + public function handle() + { + $pluginsDirectory = $this->argument('wordpressPath').'/wp-content/plugins'; + $pluginDirectory = $pluginsDirectory.'/'.basename($this->app->filename, '.php'); + + if (!is_dir($pluginsDirectory)) { + return $this->error('Unable to locate plugin directory for wordpress install at '.$this->argument('wordpressPath')); + } + + if (file_exists($pluginDirectory)) { + if (!$this->option('f')) { + return $this->error('File or folder already exists at '.$pluginDirectory.'. Use -f option to overwrite it.'); + } +dd($pluginDirectory); + // $this->fileManager->deleteDirectory($pluginDirectory); + } + + symlink($this->app->basePath(), $pluginDirectory); + + $this->info('Plugin installed via symlink at '.$pluginDirectory); + } +} + From bc4c13f8c27e3f3f2a3f19cb01aab773f54f090f Mon Sep 17 00:00:00 2001 From: Andrew Feeney Date: Mon, 4 Sep 2017 09:26:23 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Arc/Application.php | 1 + src/Arc/Console/LinkPluginCommand.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Arc/Application.php b/src/Arc/Application.php index 96f4050..c1f16c4 100644 --- a/src/Arc/Application.php +++ b/src/Arc/Application.php @@ -1028,6 +1028,7 @@ public function abort($code, $message = '', array $headers = []) if ($code == 404) { throw new NotFoundHttpException($message); } + throw new HttpException($code, $message, null, $headers); } diff --git a/src/Arc/Console/LinkPluginCommand.php b/src/Arc/Console/LinkPluginCommand.php index aedc508..786b154 100644 --- a/src/Arc/Console/LinkPluginCommand.php +++ b/src/Arc/Console/LinkPluginCommand.php @@ -50,7 +50,7 @@ public function handle() if (!$this->option('f')) { return $this->error('File or folder already exists at '.$pluginDirectory.'. Use -f option to overwrite it.'); } -dd($pluginDirectory); + dd($pluginDirectory); // $this->fileManager->deleteDirectory($pluginDirectory); } @@ -59,4 +59,3 @@ public function handle() $this->info('Plugin installed via symlink at '.$pluginDirectory); } } -