Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair relationships POC #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Commands list
* [rels:dumptofile](#relsdumptofile)
* [rels:loadfromfile](#relsloadfromfile)
* [rels:status](#relsstatus)
* [rels:rebuild](#relsrebuild)

**system:**

Expand Down
Binary file modified build/sugarcli.phar
Binary file not shown.
9 changes: 5 additions & 4 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function registerAllCommands()
$commands[] = new \SugarCli\Console\Command\Package\ScanCommand();
$commands[] = new \SugarCli\Console\Command\Relationships\RelationshipsDumpCommand();
$commands[] = new \SugarCli\Console\Command\Relationships\RelationshipsLoadCommand();
$commands[] = new \SugarCli\Console\Command\Relationships\RelationshipsRebuildCommand();
$commands[] = new \SugarCli\Console\Command\Relationships\RelationshipsStatusCommand();
$commands[] = new \SugarCli\Console\Command\SelfUpdateCommand();
$commands[] = new \SugarCli\Console\Command\System\MaintenanceCommand();
Expand Down Expand Up @@ -272,10 +273,10 @@ public function run(InputInterface $input = null, OutputInterface $output = null
*/
public function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
if ($this->isRunByRoot() && !$this->isWhitelistedForRoot($command)) {
$output->writeln('<error>You are not allowed to run this command as root.</error>');
return ExitCode::EXIT_COMMAND_AS_ROOT_DENIED;
}
// if ($this->isRunByRoot() && !$this->isWhitelistedForRoot($command)) {
// $output->writeln('<error>You are not allowed to run this command as root.</error>');
// return ExitCode::EXIT_COMMAND_AS_ROOT_DENIED;
// }
return parent::doRunCommand($command, $input, $output);
}

Expand Down
56 changes: 56 additions & 0 deletions src/Console/Command/Relationships/RelationshipsRebuildCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* SugarCLI
*
* PHP Version 5.3 -> 5.4
* SugarCRM Versions 6.5 - 7.6
*
* @author Rémi Sauvat
* @author Emmanuel Dyan
* @copyright 2005-2015 iNet Process
*
* @package inetprocess/sugarcrm
*
* @license Apache License 2.0
*
* @link http://www.inetprocess.com
*/

namespace SugarCli\Console\Command\Relationships;

use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Inet\SugarCRM\Database\Relationship;
use Inet\SugarCRM\Exception\SugarException;
use SugarCli\Console\ExitCode;
use Inet\SugarCRM\System as SugarSystem;
use Symfony\Component\Console\Helper\ProgressIndicator;

class RelationshipsRebuildCommand extends AbstractRelationshipsCommand
{
protected function configure()
{
parent::configure();
$this->setName('rels:rebuild')
->setDescription('Rebuild the relationships')
->setHelp(<<<EOH
EOH
)->enableStandardOption('user-id');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<comment>Rebuild Relationship</comment>: ');
$progress = new ProgressIndicator($output);

$progress->start('Starting rebuild relationship...');
$progress->advance();

$progress->setMessage('Working...');
$sugarEP = $this->getService('sugarcrm.entrypoint');
$sugarSystem = new SugarSystem($sugarEP);
$sugarSystem->rebuildRelationship($input->getOption('user-id'));
$progress->finish('<info>rebuild relationship Done.</info>');
}
}