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
2 changes: 1 addition & 1 deletion app/commands/ConvertExerciseAttachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function __construct(
$this->fileStorageManager = $fileStorageManager;
}

protected function configure()
protected function configure(): void
{
$this->addOption(
'apiBase',
Expand Down
44 changes: 20 additions & 24 deletions app/commands/DoctrineFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use App\Model\Entity\Pipeline;
use Doctrine\DBAL;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Id\AssignedGenerator;
use Nette\Utils\Finder;
Expand Down Expand Up @@ -64,7 +66,7 @@ public function __construct(
/**
* Register the 'db:fill' command in the framework
*/
protected function configure()
protected function configure(): void
{
$this->addOption(
'test',
Expand Down Expand Up @@ -121,50 +123,44 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
protected function clearDatabase()
{
$platform = $this->dbConnection->getDatabasePlatform()->getName();
$platform = $this->dbConnection->getDatabasePlatform();

if ($platform === 'mysql') {
if ($platform instanceof AbstractMySQLPlatform) {
$this->dbConnection->executeQuery("SET FOREIGN_KEY_CHECKS = 0");
} else {
if ($platform === 'sqlite') {
$this->dbConnection->executeQuery("PRAGMA foreign_keys = OFF");
}
} elseif ($platform instanceof SQLitePlatform) {
$this->dbConnection->executeQuery("PRAGMA foreign_keys = OFF");
}

foreach ($this->dbConnection->getSchemaManager()->listTables() as $table) {

foreach ($this->dbConnection->createSchemaManager()->introspectTables() as $table) {
$tableName = $table->getName();
if ($tableName === "doctrine_migrations") {
// do not clear migrations table... it is crucial
continue;
}

if ($platform === 'mysql') {
if ($platform instanceof AbstractMySQLPlatform) {
if (!str_starts_with($tableName, '``')) {
$tableName = '`' . $tableName . '`';
}
} else {
if ($platform === 'sqlite') {
if (!str_starts_with($tableName, '``')) {
$tableName = '"' . $tableName . '"';
}
} elseif ($platform instanceof SQLitePlatform) {
if (!str_starts_with($tableName, '``')) {
$tableName = '"' . $tableName . '"';
}
}

if ($platform === "mysql") {

if ($platform instanceof AbstractMySQLPlatform) {
$this->dbConnection->executeQuery(sprintf("TRUNCATE %s", $tableName));
} else {
if ($platform === "sqlite") {
$this->dbConnection->executeQuery(sprintf("DELETE FROM %s", $tableName));
}
} elseif ($platform instanceof SQLitePlatform) {
$this->dbConnection->executeQuery(sprintf("DELETE FROM %s", $tableName));
}
}

if ($platform === 'pdo_mysql') {
if ($platform instanceof AbstractMySQLPlatform) {
$this->dbConnection->executeQuery("SET FOREIGN_KEY_CHECKS = 1");
} else {
if ($platform === 'sqlite') {
$this->dbConnection->executeQuery("PRAGMA foreign_keys = ON");
}
} elseif ($platform instanceof SQLitePlatform) {
$this->dbConnection->executeQuery("PRAGMA foreign_keys = ON");
}
}
}
2 changes: 1 addition & 1 deletion app/commands/PlagiarismDetectionAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(AccessManager $accessManager, Users $users)
$this->users = $users;
}

protected function configure()
protected function configure(): void
{
$this->addArgument('userId', InputArgument::REQUIRED, 'ID of the admin owning the token.');
$this->addOption(
Expand Down
2 changes: 1 addition & 1 deletion app/commands/RemoveInactiveUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(array $config, Users $users, AnonymizationHelper $an
$this->anonymizationHelper = $anonymizationHelper;
}

protected function configure()
protected function configure(): void
{
$this->addOption(
'report',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/runtimes/FixConfigVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(
$this->exerciseConfigHelper = $exerciseConfigHelper;
}

protected function configure()
protected function configure(): void
{
$this->addArgument(
'runtime',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/runtimes/FixExerciseConfigs.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
$this->exerciseConfigs = $exerciseConfigs;
}

protected function configure()
protected function configure(): void
{
$this->addArgument(
'runtime',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/runtimes/RuntimeExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
$this->fileManager = $fileManager;
}

protected function configure()
protected function configure(): void
{
$this->addArgument('runtime', InputArgument::REQUIRED, 'ID of the runtime environment to be exported.')
->addArgument('saveAs', InputArgument::REQUIRED, 'Path to the output ZIP archive.');
Expand Down
2 changes: 1 addition & 1 deletion app/commands/runtimes/RuntimeImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(
$this->configValidator = $configValidator;
}

protected function configure()
protected function configure(): void
{
$this->addArgument(
'zipFile',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/security/ListExamEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(GroupExamLocks $examLocks)
$this->examLocks = $examLocks;
}

protected function configure()
protected function configure(): void
{
$this->addOption(
'from',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/security/ListSecurityEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(SecurityEvents $events)
$this->events = $events;
}

protected function configure()
protected function configure(): void
{
$this->addOption(
'from',
Expand Down
12 changes: 7 additions & 5 deletions app/config/config.local.neon.example
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ parameters:

# The most important part - a database system connection
nettrine.dbal:
connection:
host: "localhost"
user: "recodex"
password: "someSecretPasswordYouNeedToSetYourself"
dbname: "recodex"
connections:
default:
host: "localhost"
user: "recodex"
password: "someSecretPasswordYouNeedToSetYourself"
dbname: "recodex"
charset: utf8mb4

# configure mailing module
mail:
Expand Down
64 changes: 26 additions & 38 deletions app/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,8 @@ acl:

extensions:
console: Contributte\Console\DI\ConsoleExtension(%consoleMode%)
nettrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension
nettrine.cache: Nettrine\Cache\DI\CacheExtension
nettrine.dbal: Nettrine\DBAL\DI\DbalExtension
nettrine.dbal.console: Nettrine\DBAL\DI\DbalConsoleExtension
nettrine.orm: Nettrine\ORM\DI\OrmExtension
nettrine.orm.cache: Nettrine\ORM\DI\OrmCacheExtension
nettrine.orm.console: Nettrine\ORM\DI\OrmConsoleExtension(%consoleMode%)
nettrine.orm.annotations: Nettrine\ORM\DI\OrmAnnotationsExtension
nettrine.migrations: Nettrine\Migrations\DI\MigrationsExtension
nettrine.extensions.atlantic18: Nettrine\Extensions\Atlantic18\DI\Atlantic18BehaviorExtension
fixtures: Zenify\DoctrineFixtures\DI\FixturesExtension
Expand Down Expand Up @@ -486,39 +480,33 @@ nettrine.dbal:
debug:
panel: false
sourcePaths: [%appDir%]
connection:
driver: pdo_mysql
host: localhost
dbname: 'recodex-api'
user: 'root'
password: ''
charset: utf8mb4
types:
bit: Doctrine\DBAL\Types\BooleanType
datetime: DoctrineExtensions\DBAL\Types\UTCDateTimeType
uuid: Ramsey\Uuid\Doctrine\UuidType
defaultTableOptions:
charset: utf8mb4
collate: utf8mb4_unicode_ci
types:
bit: Doctrine\DBAL\Types\BooleanType
datetime: DoctrineExtensions\DBAL\Types\UTCDateTimeType
uuid: Ramsey\Uuid\Doctrine\UuidType
connections:
default:
driver: pdo_mysql
host: localhost
# dbname: 'recodex-api'
# charset: utf8mb4
defaultTableOptions:
charset: utf8mb4
collate: utf8mb4_unicode_ci

nettrine.orm:
configuration:
autoGenerateProxyClasses: true
customStringFunctions:
coalesce_sub: DoctrineExtensions\Query\Functions\CoalesceSubselectsFunction
type: DoctrineExtensions\Query\Functions\TypeFunction

nettrine.orm.annotations:
mapping:
App\Model\Entity: %appDir%/model/entity

nettrine.annotations:
ignore:
- LoggedIn
- POST
- GET
- PUT
- DELETE
managers:
default:
connection: default
mapping:
App:
directories: [%appDir%/model/entity]
namespace: App\Model\Entity
autoGenerateProxyClasses: true
lazyNativeObjects: true
customStringFunctions:
coalesce_sub: DoctrineExtensions\Query\Functions\CoalesceSubselectsFunction
type: DoctrineExtensions\Query\Functions\TypeFunction

nettrine.extensions.atlantic18:
softDeleteable: true
Expand All @@ -534,4 +522,4 @@ fixtures:
seed: 1

console:
name: ReCodEx Core API
name: ReCodEx Core API
Loading
Loading