|
@@ -4,6 +4,7 @@ namespace Opentalent\OtAdmin\Command;
|
|
|
|
|
|
|
|
|
|
|
|
|
use Opentalent\OtAdmin\Controller\SiteController;
|
|
use Opentalent\OtAdmin\Controller\SiteController;
|
|
|
|
|
+use Opentalent\OtCore\Exception\NoSuchOrganizationException;
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
@@ -46,6 +47,13 @@ class UpdateSiteCommand extends Command
|
|
|
'organization-id',
|
|
'organization-id',
|
|
|
InputArgument::OPTIONAL,
|
|
InputArgument::OPTIONAL,
|
|
|
"The organization's id in the opentalent DB"
|
|
"The organization's id in the opentalent DB"
|
|
|
|
|
+ )
|
|
|
|
|
+ ->addOption(
|
|
|
|
|
+ 'delete',
|
|
|
|
|
+ null,
|
|
|
|
|
+ InputOption::VALUE_NONE,
|
|
|
|
|
+ "Performs a soft deletion of the websites when the organization does not exist anymore " .
|
|
|
|
|
+ "in the Opentalent DB. (This only applies if the --all option is used)"
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -60,7 +68,7 @@ class UpdateSiteCommand extends Command
|
|
|
{
|
|
{
|
|
|
$org_id = $input->getArgument('organization-id');
|
|
$org_id = $input->getArgument('organization-id');
|
|
|
$all = $input->getOption('all');
|
|
$all = $input->getOption('all');
|
|
|
- $hard = $input->getOption('hard');
|
|
|
|
|
|
|
+ $delete = $input->getOption('delete');
|
|
|
|
|
|
|
|
if ($all && $org_id) {
|
|
if ($all && $org_id) {
|
|
|
throw new \InvalidArgumentException("You can not pass both an organization id and the --all option");
|
|
throw new \InvalidArgumentException("You can not pass both an organization id and the --all option");
|
|
@@ -68,6 +76,9 @@ class UpdateSiteCommand extends Command
|
|
|
if (!$all && !$org_id) {
|
|
if (!$all && !$org_id) {
|
|
|
throw new \InvalidArgumentException("You shall either pass an organization id or use the --all option");
|
|
throw new \InvalidArgumentException("You shall either pass an organization id or use the --all option");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!$all && $delete) {
|
|
|
|
|
+ throw new \InvalidArgumentException("The delete option only applies when the --all option is passed");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$io = new SymfonyStyle($input, $output);
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
|
|
|
@@ -90,6 +101,12 @@ class UpdateSiteCommand extends Command
|
|
|
$org_id = $site['organization_id'];
|
|
$org_id = $site['organization_id'];
|
|
|
try {
|
|
try {
|
|
|
$siteController->updateSiteAction($org_id);
|
|
$siteController->updateSiteAction($org_id);
|
|
|
|
|
+ } catch (NoSuchOrganizationException $e) {
|
|
|
|
|
+ if ($delete) {
|
|
|
|
|
+ $siteController->deleteSiteAction($org_id);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw $e;
|
|
|
|
|
+ }
|
|
|
} catch (\Throwable $e) {
|
|
} catch (\Throwable $e) {
|
|
|
$io->error('Organization Id: ' . $org_id . ' - ' . $e->getMessage());
|
|
$io->error('Organization Id: ' . $org_id . ' - ' . $e->getMessage());
|
|
|
}
|
|
}
|
|
@@ -99,7 +116,7 @@ class UpdateSiteCommand extends Command
|
|
|
|
|
|
|
|
$io->success(sprintf("The websites have all been updated"));
|
|
$io->success(sprintf("The websites have all been updated"));
|
|
|
} else {
|
|
} else {
|
|
|
- $rootUid = $siteController->updateSiteAction($org_id, $hard);
|
|
|
|
|
|
|
+ $rootUid = $siteController->updateSiteAction($org_id);
|
|
|
$io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
|
|
$io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|