Skip to content
Merged
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
14 changes: 6 additions & 8 deletions app/commands/DoctrineFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Doctrine\DBAL;
use Nette\Utils\Finder;
use Nette\Utils\Strings;
use SplFileInfo;
use Nette\Utils\FileInfo;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -18,10 +18,9 @@
* in add/fixtures directory. Also, 'db:fill' command is registered to provide
* convenient usage of this function.
*/
#[AsCommand(name: 'db:fill', description: 'Clear the database and fill it with initial data.')]
class DoctrineFixtures extends Command
{
protected static $defaultName = 'db:fill';

/**
* Loader of YAML files with database values
* @var AliceLoaderInterface
Expand Down Expand Up @@ -53,7 +52,6 @@ public function __construct(
*/
protected function configure()
{
$this->setName('db:fill')->setDescription('Clear the database and fill it with initial data.');
$this->addOption(
'test',
't',
Expand All @@ -70,7 +68,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->clearDatabase();

Expand All @@ -80,10 +78,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($input->getArgument("groups") as $group) {
$groupFiles = [];

/** @var SplFileInfo $file */
/** @var FileInfo $file */
foreach (
Finder::findFiles("*.neon", "*.yml", "*.yaml", "*.json")
->in($fixtureDir . "/" . $group) as $file
->in($fixtureDir . "/" . $group) as $file
) {
$groupFiles[] = $file->getRealPath();
}
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/AddAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Helpers\RecodexApiHelper;
use App\Model\Repository\Users;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -13,10 +14,9 @@
* Add admin into a group as a member.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:add-admin', description: 'Add admin into a group as a member.')]
class RecodexAddAdmin extends BaseCommand
{
protected static $defaultName = 'recodex:add-admin';

/**
* @var RecodexApiHelper
*/
Expand All @@ -43,7 +43,6 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Add admin into a group as a member.');
$this->addArgument('groupId', InputArgument::REQUIRED, 'ID of the group to which the admin will be added.');
$this->addArgument('adminId', InputArgument::REQUIRED, 'ID of the admin to be added.');
}
Expand All @@ -53,7 +52,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/AddAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console;

use App\Helpers\RecodexApiHelper;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -12,10 +13,9 @@
* Add external attribute to ReCodEx group.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:add-attribute', description: 'Add external attribute to ReCodEx group.')]
class RecodexAddAttribute extends BaseCommand
{
protected static $defaultName = 'recodex:add-attribute';

/**
* @var RecodexApiHelper
*/
Expand All @@ -35,7 +35,6 @@ public function __construct(RecodexApiHelper $recodexApi)
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Add external attribute to ReCodEx group.');
$this->addArgument('groupId', InputArgument::REQUIRED, 'ID of the group to which the attribute will be added.');
$this->addArgument('key', InputArgument::REQUIRED, 'The key of the attribute being added.');
$this->addArgument('value', InputArgument::REQUIRED, 'The value of the attribute being added.');
Expand All @@ -46,7 +45,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/AddStudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Helpers\RecodexApiHelper;
use App\Model\Repository\Users;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -13,10 +14,9 @@
* Add student into a group as a member.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:add-student', description: 'Add student into a group as a member.')]
class RecodexAddStudent extends BaseCommand
{
protected static $defaultName = 'recodex:add-student';

/**
* @var RecodexApiHelper
*/
Expand All @@ -43,7 +43,6 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Add student into a group as a member.');
$this->addArgument('groupId', InputArgument::REQUIRED, 'ID of the group to which the student will be added.');
$this->addArgument('studentId', InputArgument::REQUIRED, 'ID of the student to be added.');
}
Expand All @@ -53,7 +52,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/CreateGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Helpers\RecodexApiHelper;
use App\Model\Repository\SisScheduleEvents;
use App\Model\Repository\Users;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -14,10 +15,9 @@
* Create a new group in ReCodEx form selected SIS event.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:create-group', description: 'Create a new group in ReCodEx.')]
class RecodexCreateGroup extends BaseCommand
{
protected static $defaultName = 'recodex:create-group';

/**
* @var RecodexApiHelper
*/
Expand Down Expand Up @@ -51,7 +51,6 @@ public function __construct(RecodexApiHelper $recodexApi, SisScheduleEvents $sis
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Create a new group in ReCodEx.');
$this->addArgument('eventId', InputArgument::REQUIRED, 'The SIS ID of the event associated with the group.');
$this->addArgument('parentId', InputArgument::REQUIRED, 'ReCodEx ID of the the parent group.');
$this->addArgument('adminId', InputArgument::REQUIRED, 'ReCodEx ID of the admin of the newly created group.');
Expand All @@ -62,7 +61,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Model\Entity\SisAffiliation;
use App\Model\Repository\SisScheduleEvents;
use App\Model\Repository\Users;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -16,10 +17,9 @@
* Load groups from ReCodEx API for given user and print them out.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:groups', description: 'Load groups from ReCodEx API for given user.')]
class RecodexGroups extends BaseCommand
{
protected static $defaultName = 'recodex:groups';

/**
* @var RecodexApiHelper
*/
Expand Down Expand Up @@ -53,7 +53,6 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users, SisSched
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Load groups from ReCodEx API for given user.');
$this->addArgument('ukco', InputArgument::REQUIRED, 'SIS ID of the user whose groups are being loaded.');
}

Expand Down Expand Up @@ -95,7 +94,7 @@ private static function printGroups(OutputInterface $output, array $groups): voi
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/RemoveAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Helpers\RecodexApiHelper;
use App\Model\Repository\Users;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -13,10 +14,9 @@
* Remove admin from a group.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:remove-admin', description: 'Remove admin from a group.')]
class RecodexRemoveAdmin extends BaseCommand
{
protected static $defaultName = 'recodex:remove-admin';

/**
* @var RecodexApiHelper
*/
Expand All @@ -43,7 +43,6 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Remove admin from a group.');
$this->addArgument(
'groupId',
InputArgument::REQUIRED,
Expand All @@ -57,7 +56,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/RemoveAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console;

use App\Helpers\RecodexApiHelper;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -12,10 +13,9 @@
* Remove external attribute from ReCodEx group.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:remove-attribute', description: 'Remove external attribute from ReCodEx group.')]
class RecodexRemoveAttribute extends BaseCommand
{
protected static $defaultName = 'recodex:remove-attribute';

/**
* @var RecodexApiHelper
*/
Expand All @@ -35,7 +35,6 @@ public function __construct(RecodexApiHelper $recodexApi)
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Remove external attribute from ReCodEx group.');
$this->addArgument(
'groupId',
InputArgument::REQUIRED,
Expand All @@ -50,7 +49,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
7 changes: 3 additions & 4 deletions app/commands/Recodex/RemoveStudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Helpers\RecodexApiHelper;
use App\Model\Repository\Users;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -13,10 +14,9 @@
* Remove student from a group.
* This command is mainly designed for debugging ReCodEx API integration.
*/
#[AsCommand(name: 'recodex:remove-student', description: 'Remove student from a group.')]
class RecodexRemoveStudent extends BaseCommand
{
protected static $defaultName = 'recodex:remove-student';

/**
* @var RecodexApiHelper
*/
Expand All @@ -43,7 +43,6 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Remove student from a group.');
$this->addArgument(
'groupId',
InputArgument::REQUIRED,
Expand All @@ -57,7 +56,7 @@ protected function configure()
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
14 changes: 3 additions & 11 deletions app/commands/Recodex/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console;

use App\Helpers\RecodexApiHelper;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -11,10 +12,9 @@
* Test the ReCodEx API by manually translating temp token into full token.
* This command is mainly for debugging purposes.
*/
#[AsCommand(name: 'recodex:token', description: 'Translate tmp token into full token and get user info.')]
class RecodexToken extends BaseCommand
{
protected static $defaultName = 'recodex:token';

/**
* @var RecodexApiHelper
*/
Expand All @@ -29,20 +29,12 @@ public function __construct(RecodexApiHelper $recodexApi)
$this->recodexApi = $recodexApi;
}

/**
* Register the command.
*/
protected function configure()
{
$this->setName(self::$defaultName)->setDescription('Translate tmp token into full token and get user info.');
}

/**
* @param InputInterface $input Console input, not used
* @param OutputInterface $output Console output for logging
* @return int 0 on success, 1 on error
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;
Expand Down
Loading