Commit 7d054155 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Possibilité d'accéder à la BDD Admin depuis l'application (pour usage dans UnicaenCode ou autre...)

parent cae48f2e
Loading
Loading
Loading
Loading
+17 −26
Original line number Diff line number Diff line
@@ -7,22 +7,7 @@
 * @var $sl         \Zend\ServiceManager\ServiceLocatorInterface
 */

spl_autoload_register(function ($class) {
    if (0 === strpos($class, 'BddAdmin')) {
        $dir   = dirname(__DIR__) . '/admin/src/';
        $class = $dir . str_replace('\\', '/', $class) . '.php';

        require_once $class;
    }
});

$bdd    = new \BddAdmin\Bdd([
    'host'     => AppConfig::get('bdd', 'host'),
    'port'     => AppConfig::get('bdd', 'port'),
    'dbname'   => AppConfig::get('bdd', 'dbname'),
    'username' => AppConfig::get('bdd', 'username'),
    'password' => AppConfig::get('bdd', 'password'),
]);
$bdd    = adminBdd();
$schema = new \BddAdmin\Schema($bdd);

/*$tables = [
@@ -49,7 +34,7 @@ $schema = new \BddAdmin\Schema($bdd);

$list = [
    'ANNEE', 'INTERVENANT', 'CORPS', 'GRADE', 'GROUPE_TYPE_FORMATION', 'TYPE_FORMATION', 'ETAPE', 'ELEMENT_PEDAGOGIQUE',
'CHEMIN_PEDAGOGIQUE', 'VOLUME_HORAIRE_ENS', 'TYPE_INTERVENTION'
    'CHEMIN_PEDAGOGIQUE', 'VOLUME_HORAIRE_ENS', 'TYPE_INTERVENTION',
];

$tables = [];
@@ -144,7 +129,13 @@ foreach ($cls as $cl) {
                    },
                    new go.Binding("text", "name")),
                $(go.TextBlock,
                    {margin: new go.Margin(0, 5), column: 2,stroke: "#ef9b0b",font: "normal 9px sans-serif", alignment: go.Spot.Left},
                    {
                        margin: new go.Margin(0, 5),
                        column: 2,
                        stroke: "#ef9b0b",
                        font: "normal 9px sans-serif",
                        alignment: go.Spot.Left
                    },
                    new go.Binding("text", "type"))
            );

+16 −5
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@
include_once dirname(__DIR__) . '/module/Application/Application.php';





class AppConfig
{
    const LOCAL_APPLICATION_CONFIG_FILE = __DIR__ . '/../config.local.php';
@@ -52,6 +55,12 @@ class AppConfig
            }
        }

        if (self::$config && $section) {
            if (isset(self::$config[$section])) {
                return self::$config[$section];
            }
        }

        return self::$config;
    }

@@ -143,6 +152,7 @@ class AppConfig
        if (!self::$global) {
            self::$global = self::makeGlobal();
        }

        return self::$global;
    }
}
@@ -152,4 +162,5 @@ class AppConfig


AppConfig::init();

return AppConfig::getGlobal();
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -108,3 +108,22 @@ function vhlDump(\Application\Entity\VolumeHoraireListe $volumeHoraireListe): \O

    return $dumper;
}


function adminBdd(): \BddAdmin\Bdd
{
    if (!class_exists('BddAdmin\Bdd')) {
        spl_autoload_register(function ($class) {
            if (0 === strpos($class, 'BddAdmin')) {
                $dir   = getcwd() . '/admin/src/';
                $class = $dir . str_replace('\\', '/', $class) . '.php';

                require_once $class;
            }
        });
    }

    $bdd = new BddAdmin\Bdd(AppConfig::get('bdd'));

    return $bdd;
}
 No newline at end of file