Skip to content

Commit

Permalink
Minor - flint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Dec 16, 2019
1 parent c3b9456 commit 8983b3c
Show file tree
Hide file tree
Showing 62 changed files with 2,180 additions and 2,223 deletions.
8 changes: 5 additions & 3 deletions chash.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Command-line tool to do things more swiftly in Chamilo.
* To add support for a new command see the Console Component read:
* To add support for a new command see the Console Component read:.
*
* https://speakerdeck.com/hhamon/symfony-extending-the-console-component
* http://symfony.com/doc/2.0/components/console/introduction.html
Expand All @@ -28,11 +28,13 @@
use Symfony\Component\Console\Application;

$helpers = [
'configuration' => new Chash\Helpers\ConfigurationHelper()
'configuration' => new Chash\Helpers\ConfigurationHelper(),
];

$application = new Application('Chamilo Command Line Interface', '1.0');

$helpers = [
'configuration' => new Chash\Helpers\ConfigurationHelper()
];
$helperSet = $application->getHelperSet();
foreach ($helpers as $name => $helper) {
$helperSet->set($helper, $name);
Expand Down
2 changes: 1 addition & 1 deletion createPhar.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Make sure you have this setting in your php.ini (cli)
* phar.readonly = Off
* phar.readonly = Off.
*/
error_reporting(-1);

Expand Down
25 changes: 13 additions & 12 deletions src/Command/Chash/SelfUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Chash\Command\Chash;

use Alchemy\Zippy\Zippy;
use Composer\IO\NullIO;
use Composer\Util\RemoteFilesystem;
use Doctrine\Migrations\Tools\Console\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console;
use Composer\Util\RemoteFilesystem;
use Composer\IO\NullIO;
use Alchemy\Zippy\Zippy;
use Symfony\Component\Console\Input\InputOption;

/**
* Class SelfUpdateCommand
* Class SelfUpdateCommand.
*/
class SelfUpdateCommand extends AbstractCommand
{
Expand All @@ -25,29 +25,28 @@ protected function configure(): void
}

/**
* Executes a command via CLI
*
* @param Console\Input\InputInterface $input
* @param Console\Output\OutputInterface $output
* Executes a command via CLI.
*
* @return int|null|void
* @return int|void|null
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$tempFolder = $input->getOption('temp-folder');
$destinationFolder = $input->getOption('src-destination');

if (empty($destinationFolder)) {
$destinationFolder = realpath(__DIR__.'/../../../chash/');
$destinationFolder = realpath(__DIR__.'/../../../chash/');
}

if (!is_writable($destinationFolder)) {
$output->writeln('Chash update failed: the "'.$destinationFolder.'" directory used to update the Chash file could not be written');

return 0;
}

if (!is_writable($tempFolder)) {
$output->writeln('Chash update failed: the "'.$tempFolder.'" directory used to download the temp file could not be written');

return 0;
}

Expand All @@ -62,7 +61,8 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
$rfs->copy('github.com', 'https://github.com/chamilo/chash/archive/master.zip', $tempFile);

if (!file_exists($tempFile)) {
$output->writeln('Chash update failed: the "'.$tempFile. '" file could not be written');
$output->writeln('Chash update failed: the "'.$tempFile.'" file could not be written');

return 0;
}

Expand All @@ -78,6 +78,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
} catch (\Alchemy\Zippy\Exception\RunTimeException $e) {
$output->writeln("<comment>Chash update failed during unzip.");
$output->writeln($e->getMessage());

return 0;
}
$fs = new \Symfony\Component\Filesystem\Filesystem();
Expand Down
36 changes: 16 additions & 20 deletions src/Command/Chash/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@
namespace Chash\Command\Chash;

use Doctrine\Migrations\Tools\Console\Command\AbstractCommand;
use Symfony\Component\Console;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Dumper;

/**
* Class SetupCommand
* Class SetupCommand.
*/
class SetupCommand extends AbstractCommand
{
public $migrationFile;

/**
* Gets the migration file path.
*
* @return string
*/
public function getMigrationFile()
{
return $this->migrationFile;
}

protected function configure(): void
{
$this
Expand All @@ -27,12 +37,9 @@ protected function configure(): void
}

/**
* Executes a command via CLI
*
* @param Console\Input\InputInterface $input
* @param Console\Output\OutputInterface $output
* Executes a command via CLI.
*
* @return int|null|void
* @return int|void|null
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
Expand All @@ -56,8 +63,6 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
if ($version == '110') {
$file = $chamiloRoot.'app/config/migrations110.yml';



$this->migrationFile = $file;

return 1;
Expand All @@ -74,7 +79,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
'name' => 'Chamilo Migrations',
'migrations_namespace' => 'Application\Migrations\Schema\V111',
'table_name' => 'version',
'migrations_directory' => $migrationsFolder
'migrations_directory' => $migrationsFolder,
];

$dumper = new Dumper();
Expand All @@ -90,13 +95,4 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
$output->writeln("<comment>Chash migrations.yml saved: $file</comment>");
$this->migrationFile = $file;
}

/**
* Gets the migration file path
* @return string
*/
public function getMigrationFile()
{
return $this->migrationFile;
}
}
10 changes: 3 additions & 7 deletions src/Command/Common/ChamiloEmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
namespace Chash\Command\Common;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use Symfony\Component\Console\Formatter\OutputFormatterStyle;

/**
* Class CommonChamiloUserCommand
* Class CommonChamiloUserCommand.
*
* @package Chash\Command\User
*/
class ChamiloEmailCommand extends Command
Expand All @@ -28,9 +26,7 @@ protected function configure(): void
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand Down
5 changes: 1 addition & 4 deletions src/Command/Common/ChamiloUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Chash\Command\Common;

use Chash\Command\Common\DatabaseCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -14,9 +13,7 @@ protected function configure(): void
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand Down
Loading

0 comments on commit 8983b3c

Please sign in to comment.