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 new file mode 100644 index 0000000..786b154 --- /dev/null +++ b/src/Arc/Console/LinkPluginCommand.php @@ -0,0 +1,61 @@ +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); + } +}