Skip to content
Snippets Groups Projects
Commit 9420e3c5 authored by François Agneray's avatar François Agneray
Browse files

Fixed bug: DATABASE_DEV_MODE=0

parent 463ef39a
No related branches found
No related tags found
1 merge request!72Develop
Pipeline #8018 passed
Pipeline: anis-next

#8019

    ......@@ -3,6 +3,7 @@ nbproject/
    .idea/
    vendor/*
    phpunit-coverage/
    doctrine_cache/
    coverage/
    data/
    build/*
    ......
    ......@@ -22,10 +22,17 @@ $container->set('em', function (ContainerInterface $c) {
    $settings = $c->get(SETTINGS)['database'];
    $devMode = boolval($settings['dev_mode']);
    $proxyDir = getcwd() . '/../doctrine-proxy';
    $cache = null;
    if ($devMode == false) {
    $cache = new \Doctrine\Common\Cache\ApcuCache();
    if ($devMode) {
    $cache = \Doctrine\Common\Cache\Psr6\DoctrineProvider::wrap(
    new \Symfony\Component\Cache\Adapter\ArrayAdapter()
    );
    } else {
    $cache = \Doctrine\Common\Cache\Psr6\DoctrineProvider::wrap(
    new \Symfony\Component\Cache\Adapter\FilesystemAdapter(directory: '/project/doctrine_cache')
    );
    }
    $dc = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
    array('src/Entity'),
    $devMode,
    ......@@ -33,12 +40,11 @@ $container->set('em', function (ContainerInterface $c) {
    $cache
    );
    $dc->setAutogenerateProxyClasses(false);
    if ($devMode) {
    $dc->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
    } else {
    $dc->setQueryCacheImpl($cache);
    }
    return \Doctrine\ORM\EntityManager::create($settings['connection_options'], $dc);
    });
    ......
    <?php
    // File needed by doctrine cli
    require 'vendor/autoload.php';
    $settings = require './app/settings.php';
    $database = $settings['database'];
    $devMode = boolval($database['dev_mode']);
    $proxyDir = getcwd() . '/doctrine-proxy';
    $cache = null;
    if ($devMode == false) {
    $cache = new \Doctrine\Common\Cache\ApcuCache();
    }
    /*
    * This file is part of Anis Server.
    *
    * (c) Laboratoire d'Astrophysique de Marseille / CNRS
    *
    * For the full copyright and license information, please view the LICENSE
    * file that was distributed with this source code.
    */
    declare(strict_types=1);
    $c = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
    array('src/Entity'),
    $devMode,
    $proxyDir,
    $cache
    );
    $c->setAutoGenerateProxyClasses(false);
    use DI\Container;
    use Doctrine\ORM\Tools\Console\ConsoleRunner;
    if ($devMode) {
    $c->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
    } else {
    $c->setQueryCacheImpl($cache);
    }
    // Autoloading for libraries
    require __DIR__ . '/vendor/autoload.php';
    $em = \Doctrine\ORM\EntityManager::create($database['connection_options'], $c);
    // Load app constants
    require __DIR__ . '/app/constants.php';
    return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($em);
    // Create Container using PHP-DI
    $container = new Container();
    // Setup dependencies
    require __DIR__ . '/app/dependencies.php';
    return ConsoleRunner::createHelperSet($container->get('em'));
    \ No newline at end of file
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment