<?php
// DIC configuration
use Symfony\Component\Yaml\Yaml;
use DI\Container;
use Slim\Flash\Messages;

$container = new Container();


$container->set('settings', function(){
    return [
        'displayErrorDetails' => true, // set to false in production
        'addContentLengthHeader' => false, // Allow the web server to send the content-length header
        'debug' => false,
        'testing' => false,        
        'close_registration' => true,

        // Renderer settings
        'renderer' => [
            'template_path' => __DIR__ . '/../templates/',
            //'cache_path' => __DIR__.'/../templates/.cache/',
            'cache_path' => false,
            'autoreload' => true,
            'debug' => true
        ],

        
        'db' => [
            'schema' => __DIR__."/../db/schema.sql",
            'load_schema' =>  __DIR__."/../db/.schema.lock"
        ],
        'recaptcha' => [
          'secret' => "6LesRDsUAAAAAA6t3UgL4U4Foc9njmXX-8HIiLj_",
          'secrettest' => "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe",
          'sitekey' => "6LesRDsUAAAAAJvyoODvjiza9u75qEGJmbKHEV6s",
          'sitekeytest' => "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
        ],
        
    ];
});

$container->set('flash', function($c){
    $storage = [];
    return new Messages($storage);
    return new \Slim\Flash\Messages();
});



$container->set('db', function ($c) {
    $dbconf = [
        'schema' => __DIR__."/../db/schema.sql",
        'load_schema' =>  __DIR__."/../db/.schema.lock"
    ];
    $db = new DB();
    try{
        
        if(!file_exists($dbconf['load_schema'])){
          $db->loadSchema($dbconf['schema']);
          touch($dbconf['load_schema']);
        }

    }
    catch(\PDOException $e){
        echo $e->getMessage();
    }
    return $db;
});

