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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.2", "8.3"]
php: ["8.4", "8.5"]
steps:
- uses: actions/checkout@v2
- name: Setup PHP with pecl and extensions
Expand All @@ -33,7 +33,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.2", "8.3"]
php: ["8.4", "8.5"]
steps:
- uses: actions/checkout@v2
- name: Setup PHP with pecl and extensions
Expand All @@ -56,7 +56,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.2", "8.3"]
php: ["8.4", "8.5"]
steps:
- uses: actions/checkout@v2
- name: Setup PHP with pecl and extensions
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# SIS-ext-core
SIS adapter (core application) designed for creating groups and updating user data based on SIS records.

SIS adapter (core application/backend) designed for creating groups and updating user data based on SIS records.
44 changes: 20 additions & 24 deletions app/commands/DoctrineFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Console;

use Doctrine\DBAL;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\SQLitePlatform;
use Nette\Utils\Finder;
use Nette\Utils\FileInfo;
use Symfony\Component\Console\Attribute\AsCommand;
Expand Down Expand Up @@ -50,7 +52,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 @@ -101,50 +103,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/Recodex/AddAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$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 Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/AddAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(RecodexApiHelper $recodexApi)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$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.');
Expand Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/AddStudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$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 Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/CreateGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(RecodexApiHelper $recodexApi, SisScheduleEvents $sis
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$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.');
Expand Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users, SisSched
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$this->addArgument('ukco', InputArgument::REQUIRED, 'SIS ID of the user whose groups are being loaded.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/RemoveAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$this->addArgument(
'groupId',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/RemoveAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(RecodexApiHelper $recodexApi)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$this->addArgument(
'groupId',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/Recodex/RemoveStudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(RecodexApiHelper $recodexApi, Users $users)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$this->addArgument(
'groupId',
Expand Down
2 changes: 1 addition & 1 deletion app/commands/SisGetCourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$this->addArgument('ukco', InputArgument::REQUIRED, 'SIS ID of the user whose courses are being loaded.');
$this->addOption(
Expand Down
2 changes: 1 addition & 1 deletion app/commands/SisGetUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(SisHelper $sis)
/**
* Register the command.
*/
protected function configure()
protected function configure(): void
{
$this->addArgument('ukco', InputArgument::REQUIRED, 'SIS ID of the user.');
}
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 @@ -23,8 +23,10 @@ parameters:

# The most important part - a database system connection
nettrine.dbal:
connection:
host: "localhost"
user: "recodex-sis-ext"
password: "someSecretPasswordYouNeedToSetYourself"
dbname: "recodex-sis-ext"
connections:
default:
charset: utf8mb4
host: "localhost"
user: "recodex-sis-ext"
password: "someSecretPasswordYouNeedToSetYourself"
dbname: "recodex-sis-ext"
67 changes: 27 additions & 40 deletions app/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ parameters:
audience: "%webapp.address%"
expiration: 86400 # of regular auth tokens (seconds)
usedAlgorithm: HS256
verificationKey: "sis-ext-123"

recodex: # just a placeholder, this needs to be overridden in local config
apiBase: null
Expand Down Expand Up @@ -81,14 +80,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 @@ -146,48 +139,42 @@ nettrine.dbal:
debug:
panel: false
sourcePaths: [%appDir%]
connection:
driver: pdo_mysql
host: localhost
dbname: 'recodex-sis-ext'
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
# 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

nettrine.migrations:
table: doctrine_migrations # database table for applied migrations
column: version # database column for applied migrations
directory: %appDir%/../migrations # directory, where all migrations are stored
namespace: Migrations # namespace of migration classes
directories:
Migrations: %appDir%/../migrations # directory, where all migrations are stored
# namespace: Migrations # namespace of migration classes

fixtures:
locale: "en_US"
Expand Down
2 changes: 1 addition & 1 deletion app/exceptions/BadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
string $msg = 'one or more parameters are missing',
string $frontendErrorCode = FrontendErrorMappings::E400_000__BAD_REQUEST,
$frontendErrorParams = null,
Exception $previous = null
?Exception $previous = null
) {
parent::__construct(
"Bad Request - $msg",
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/Emails/EmailHelper/EmailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ public function sendFromDefault(array $to, string $locale, string $subject, stri
* @param Exception $lastMailerException Exception thrown from the sender (if any). Its message is logged as well.
* @throws Exception
*/
private function archiveMailCopy(Message $message, Exception $lastMailerException = null)
private function archiveMailCopy(Message $message, ?Exception $lastMailerException = null)
{
if (!file_exists($this->archivingDir)) {
mkdir($this->archivingDir, 0775, true); // make sure logging directory exists
}

// Logging is not that important, all following opertions fail silently.
// Logging is not that important, all following operations fail silently.
if (file_exists($this->archivingDir) && is_writeable($this->archivingDir)) {
$data = [
'----- BEGIN MAIL -----',
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/ZenifyFixtures/Alice/CustomNativeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CustomNativeLoader extends NativeLoader
* @param FakerGenerator|null $fakerGenerator
* @param ChainableParserInterface[] $parsers
*/
public function __construct(FakerGenerator $fakerGenerator = null, array $parsers)
public function __construct(?FakerGenerator $fakerGenerator = null, array $parsers = [])
{
$this->parsers = $parsers; // this needs to be first
parent::__construct($fakerGenerator);
Expand Down
Loading
Loading