<?php

if (!defined('TYPO3')) {
    die('Access denied.');
}

$GLOBALS['TYPO3_CONF_VARS']['LOG']['Opentalent']['OtCore']['writerConfiguration'] = [
    // configuration for DEBUG level log entries
    TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
        // add a FileWriter
        TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
            // configuration for the writer
            'logFile' => TYPO3\CMS\Core\Core\Environment::getVarPath() . '/log/ot_typo3.log'
        ]
    ],
    TYPO3\CMS\Core\Log\LogLevel::WARNING => [
        // add a DatabaseWriter
        TYPO3\CMS\Core\Log\Writer\DatabaseWriter::class => [
            'logTable' => 'ot_log'
        ]
    ]
];

// Because of this issue https://forge.typo3.org/issues/89449,
// we have to xclass the BackendUserAuthenticator backend middleware
// to allow public routes to be really public
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Backend\Middleware\BackendUserAuthenticator::class] = [
    'className' => Opentalent\OtCore\Middleware\OtBackendUserAuthenticator::class
];

// ** Opentalent environment variables **
// An array containing all or part of these variables could have been set before, for example
// in the AdditionalConfiguration.php file.
// In this case we merge them so that the pre-defined vars are not overridden.
// (/!\ do not forget to clear the cache after any update here)
$GLOBALS['OT'] = array_merge([
    'API_BASE_URI' => 'http://docker.nginx.opentalent.fr',
    'DB_HOST' => 'db',
    'DB_USER' => 'dbcloner',
    'DB_PASSWORD' => 'wWZ4hYcrmHLW2mUK',
    'FRAMES_BASE_URI' => 'https://local.frames.opentalent.fr',
    'WEBSITE' => 'https://local.opentalent.fr',
    'ADMIN_BASE_URL' => 'https://local.admin.opentalent.fr/',
    'DASHBOARD_URL' => 'https://local.admin.opentalent.fr/#/dashboard',
    'LOGIN_PAGE_URL' => 'https://local.admin.opentalent.fr/#/login',
    'FILE_STORAGE_URL' => 'https://local.api.opentalent.fr/app.php/_internal/secure/files/'
], ($GLOBALS['OT'] ?? []));
