From cd275554f2a2b91b3d366719b4d71a6a253175ff Mon Sep 17 00:00:00 2001 From: Oliver Buchmann Date: Thu, 29 Nov 2018 20:26:21 +0100 Subject: [PATCH] Add october:util set project --projectId=id console command (#3946) Implements #3944. Credit to @obuchmann. --- modules/system/console/OctoberUtil.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/system/console/OctoberUtil.php b/modules/system/console/OctoberUtil.php index c2ba6276a..7121a0bc5 100644 --- a/modules/system/console/OctoberUtil.php +++ b/modules/system/console/OctoberUtil.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Input\InputArgument; use System\Classes\UpdateManager; use System\Classes\CombineAssets; use Exception; +use System\Models\Parameter; /** * Console command for other utility commands. @@ -27,6 +28,7 @@ use Exception; * - compile scss: Compile registered SCSS files only. * - compile lang: Compile registered Language files only. * - set build: Pull the latest stable build number from the update gateway and set it as the current build number. + * - set project --projectId=: Set the projectId for this october instance. * * @package october\system * @author Alexey Bobkov, Samuel Georges @@ -98,6 +100,7 @@ class OctoberUtil extends Command return [ ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production.'], ['debug', null, InputOption::VALUE_NONE, 'Run the operation in debug / development mode.'], + ['projectId', null, InputOption::VALUE_REQUIRED, 'Specify a projectId for set project'], ]; } @@ -328,4 +331,24 @@ class OctoberUtil extends Command } } + protected function utilSetProject() + { + $projectId = $this->option('projectId'); + + if (empty($projectId)){ + $this->error("No projectId defined, use --projectId= to set a projectId"); + return; + } + + $manager = UpdateManager::instance(); + $result = $manager->requestProjectDetails($projectId); + + Parameter::set([ + 'system::project.id' => $projectId, + 'system::project.name' => $result['name'], + 'system::project.owner' => $result['owner'], + ]); + + } + }