private function loadDoctrine($dbname, $host, $username, $password) { $lib = APPLICATION_PATH . "/doctrine-orm"; Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($lib); if (APPLICATION_ENV == "production") { $cache = new \Doctrine\Common\Cache\ApcCache(); } else { $cache = new \Doctrine\Common\Cache\ArrayCache(); } $config = new Configuration(); $config->setMetadataCacheImpl($cache); $driverImpl = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/modules/default/models'); $config->setMetadataDriverImpl($driverImpl); $config->setQueryCacheImpl($cache); $config->setProxyDir(APPLICATION_PATH . '/Proxies'); $config->setProxyNamespace('EasyCMS\\Proxies'); if ($applicationMode == "production") { $config->setAutoGenerateProxyClasses(false); } else { $config->setAutoGenerateProxyClasses(true); } $connectionOptions = array('driver' => 'pdo_mysql', 'dbname' => $dbname, 'user' => $username, 'password' => $password, 'host' => $host); $em = EntityManager::create($connectionOptions, $config); Zend_Registry::set('**application_db_connection**', $em); }
static function getEM() { if (is_null(self::$em)) { // the connection configuration $dbParams = array('driver' => 'pdo_mysql', 'user' => Config::singleton()->get("dbuser"), 'password' => Config::singleton()->get("dbpass"), 'dbname' => Config::singleton()->get("dbname"), 'database_host' => Config::singleton()->get("dbhost")); $config = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array("app/models"), Config::singleton()->get("debug")); self::$em = Doctrine\ORM\EntityManager::create($dbParams, $config); $emConfig = self::$em->getConfiguration(); $emConfig->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\\Query\\Mysql\\Year'); $emConfig->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\\Query\\Mysql\\Month'); $emConfig->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\\Query\\Mysql\\Day'); $emConfig->addCustomDatetimeFunction('Date', 'Date'); } return self::$em; }
/** * Creates and returns a new instance of doctrine * @return EntityManager The Doctrine Entity Manager */ public function getDoctrineEntityManager() { try { require_once PATH_3RD_PARTY . '/doctrine-orm/vendor/autoload.php'; $config = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration(array(PATH_INCLUDE . '/models/mapping/yml'), true); $config->setProxyDir(PATH_INCLUDE . '/models/Proxies'); $config->setProxyNamespace('Babesk\\Proxies'); $config->addEntityNamespace('DM', 'Babesk\\ORM'); $conn = array('driver' => 'pdo_mysql', 'dbname' => $this->_databaseName, 'user' => $this->_username, 'password' => $this->_password, 'host' => $this->_host); $loader = new \Doctrine\Common\ClassLoader('Babesk', PATH_INCLUDE . '/models/Entities'); $loader->register(); $loader = new \Doctrine\Common\ClassLoader('Repository', PATH_INCLUDE . '/models'); $loader->register(); $entityManager = Doctrine\ORM\EntityManager::create($conn, $config); $entityManager->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')); return $entityManager; } catch (Exception $e) { throw new Exception('Could not set up doctrine entity manager!'); } }
/** * Get Doctrine2Cache * * @return Doctrine\Common\Cache */ public function getDoctrine2cache() { if ($this->_d2cache === null) { // Get Doctrine configuration options from the application.ini file $config = $this->getOptions(); if (!isset($config['autoload_method'])) { $config['autoload_method'] = 'git'; } switch ($config['autoload_method']) { case 'pear': require_once $config['path'] . '/Tools/Setup.php'; Doctrine\ORM\Tools\Setup::registerAutoloadPEAR(); break; case 'dir': require_once $config['path'] . '/Tools/Setup.php'; // FIXME Doctrine\ORM\Tools\Setup::registerAutoloadDirectory(); break; case 'composer': break; default: require_once $config['path'] . '/lib/Doctrine/ORM/Tools/Setup.php'; Doctrine\ORM\Tools\Setup::registerAutoloadGit($config['path']); } if ($config['type'] == 'ApcCache') { $cache = new \Doctrine\Common\Cache\ApcCache(); } elseif ($config['type'] == 'MemcacheCache') { $memcache = new Memcache(); for ($cnt = 0; $cnt < count($config['memcache']['servers']); $cnt++) { $server = $config['memcache']['servers'][$cnt]; $memcache->addServer(isset($server['host']) ? $server['host'] : '127.0.0.1', isset($server['port']) ? $server['port'] : 11211, isset($server['persistent']) ? $server['persistent'] : false, isset($server['weight']) ? $server['weight'] : 1, isset($server['timeout']) ? $server['timeout'] : 1, isset($server['retry_int']) ? $server['retry_int'] : 15); } $cache = new \Doctrine\Common\Cache\MemcacheCache(); $cache->setMemcache($memcache); } else { $cache = new \Doctrine\Common\Cache\ArrayCache(); } if (isset($config['namespace'])) { $cache->setNamespace($config['namespace']); } // stick the cache in the registry Zend_Registry::set('d2cache', $cache); $this->setDoctrine2Cache($cache); } return $this->_d2cache; }
<?php require "Doctrine/ORM/Tools/Setup.php"; Doctrine\ORM\Tools\Setup::registerAutoloadDirectory('.'); // use Doctrine\ORM\Tools\Setup; // use Doctrine\ORM\EntityManager; $isDevMode = true; // the connection configuration $dbParams = array('driver' => 'pdo_mysql', 'user' => 'lab', 'password' => '7DULcn6NaWdvVxaN', 'dbname' => 'lab', 'host' => 'localhost'); //$config = Setup::createAnnotationMetadataConfiguration(array('config/Entities/'), $isDevMode); $config = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration(array('config/yml/'), $isDevMode); $em = Doctrine\ORM\EntityManager::create($dbParams, $config); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em))); include "ORM/load.php";
<?php require_once 'Doctrine/ORM/Tools/Setup.php'; // Setup Autoloader (1) Doctrine\ORM\Tools\Setup::registerAutoloadPEAR(); // configuration (2) $config = new \Doctrine\ORM\Configuration(); // Proxies (3) $config->setProxyDir(__DIR__ . '\\Doctrine\\Proxy'); $config->setProxyNamespace('Doctrine\\Proxy'); $config->setAutoGenerateProxyClasses(true); // Driver (4) $driverImpl = new Doctrine\ORM\Mapping\Driver\YamlDriver(array(__DIR__ . '/../application/configs/schema')); $config->setMetadataDriverImpl($driverImpl); // Caching Configuration (5) $cache = new \Doctrine\Common\Cache\ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $connectionOptions = array('data_fixtures_path' => __DIR__ . '/../application/configs/data/fixtures', 'models_path' => __DIR__ . '/../application/models/doctrine/models', 'migrations_path' => __DIR__ . '/../application/configs/migrations', 'sql_path' => __DIR__ . '/../application/configs/data/sql', 'yaml_schema_path' => __DIR__ . '/../application/configs/schema', 'driver' => 'pdo_mysql', 'user' => 'vlmis', 'password' => 'v123lmis', 'dbname' => 'vlmis_zr3', 'host' => '192.168.1.72'); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $platform = $em->getConnection()->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('enum', 'string'); $platform->registerDoctrineTypeMapping('tinyblob', 'string'); \Doctrine\DBAL\Types\Type::addType('BlobType', 'Doctrine\\DBAL\\Types\\BlobType'); $platform->registerDoctrineTypeMapping('blob', 'BlobType'); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)));
$zdLib = "{$cnRoot}/../../../vendor/zendframework/library"; $doctrine = "{$cnRoot}/../../../vendor/doctrine"; $htmlpurifier = "{$cnRoot}/../../../vendor/htmlpurifier/library"; /* * Prepend the conjoon library/ and tests/ directories to the * include_path. This allows the tests to run out of the box and helps prevent * loading other copies of the framework code and tests that would supersede * this copy. */ $path = array($cnCoreLibrary, $cnCoreTests, $zdLib, $doctrine, $htmlpurifier, get_include_path()); set_include_path(implode(PATH_SEPARATOR, $path)); /** * @see Doctrine\ORM\Tools\Setup */ require_once 'Doctrine/ORM/Tools/Setup.php'; Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($doctrine); /** * @see Doctrine\Common\ClassLoader */ require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Conjoon', dirname(__FILE__) . '/../library'); $classLoader->register(); /** * @see HTMLPurifier_Bootstrap */ require_once 'HTMLPurifier/Bootstrap.php'; /** * @see HTMLPurifier.autoload */ require_once 'HTMLPurifier.autoload.php'; /*
<?php use Doctrine\ORM\EntityManager, Laravel\Autoloader, Laravel\Config, Laravel\IoC; require __DIR__ . '/lib/Doctrine/ORM/Tools/Setup.php'; Doctrine\ORM\Tools\Setup::registerAutoloadGit(__DIR__); /** * Delegate the starting to an event so we can start *after* the application bundle. * * This gives the application time to override configs before we boot Doctrine. */ Event::listen('laravel.started: doctrine', function () { /** * Resolve the cache provider implementation from the IoC container. */ if (IoC::registered('doctrine::cache.provider')) { $cache = IoC::resolve('doctrine::cache.provider'); } else { $cache = new Doctrine\Common\Cache\ArrayCache(); } /** * Register the cache provider with the Doctrine configuration. */ $config = new Doctrine\ORM\Configuration(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); /** * Resolve and register the meta-data driver. */ if (IoC::registered('doctrine::metadata.driver')) { $driverImpl = IoC::resolve('doctrine::metadata.driver', array($config)); } else {
define('VENDOR_PATH', __DIR__ . '/../../vendor/'); define('APP_PATH', __DIR__ . '/../../app/'); define('CONFIG_PATH', __DIR__ . '/../../app/config/'); define('TEMPLATE_PATH', __DIR__ . '/../../web/views/'); define('PUBLIC_PATH', __DIR__ . '/../../public/'); // Password hasing define("PBKDF2_HASH_ALGORITHM", "sha256"); define("PBKDF2_ITERATIONS", 1000); define("PBKDF2_SALT_BYTE_SIZE", 24); define("PBKDF2_HASH_BYTE_SIZE", 24); define("HASH_SECTIONS", 4); define("HASH_ALGORITHM_INDEX", 0); define("HASH_ITERATION_INDEX", 1); define("HASH_SALT_INDEX", 2); define("HASH_PBKDF2_INDEX", 3); // Registrer autoloaders require VENDOR_PATH . 'autoload.php'; // Load environment variables try { (new Dotenv\Dotenv(ROOT_PATH))->load(); } catch (Exception $e) { echo $e; } $config = ['path.root' => ROOT_PATH, 'path.public' => PUBLIC_PATH, 'path.app' => APP_PATH]; require CONFIG_PATH . 'slim.php'; require CONFIG_PATH . 'doctrine.php'; $setup = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration([APP_PATH . 'models/schemas'], getenv('APP_DEBUG')); $em = \Service\Registry::set('em', Doctrine\ORM\EntityManager::create($config['doctrine'], $setup)); $app = \Service\Registry::set('slim', new \Slim\Slim($config['slim'])); require APP_PATH . 'routes.php'; return $app;
$app->register(new Silex\Provider\TranslationServiceProvider(), array('locale_fallback' => 'en_US')); $app['translator']->addLoader('yaml', new Symfony\Component\Translation\Loader\YamlFileLoader()); /*** Application Translator ***/ $app['application.translator'] = $app->share(function () use($app) { return new \Application\Translator($app); }); /*** Application Mailer ***/ $app['application.mailer'] = $app->share(function () use($app) { return new \Application\Mailer($app); }); /***** Doctrine Database & Doctrine ORM *****/ if (isset($app['databaseOptions']) && is_array($app['databaseOptions'])) { $app->register(new Silex\Provider\DoctrineServiceProvider(), array('dbs.options' => $app['databaseOptions'])); $app->register(new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), array('orm.em.options' => array('mappings' => array(array('type' => 'annotation', 'namespace' => 'Application\\Entity', 'path' => SRC_DIR . '/Application/Entity', 'use_simple_annotation_reader' => false))), 'orm.custom.functions.string' => array('cast' => 'Oro\\ORM\\Query\\AST\\Functions\\Cast', 'group_concat' => 'Oro\\ORM\\Query\\AST\\Functions\\String\\GroupConcat'), 'orm.custom.functions.datetime' => array('date' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'time' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'timestamp' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'convert_tz' => 'Oro\\ORM\\Query\\AST\\Functions\\DateTime\\ConvertTz'), 'orm.custom.functions.numeric' => array('timestampdiff' => 'Oro\\ORM\\Query\\AST\\Functions\\Numeric\\TimestampDiff', 'dayofyear' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'dayofweek' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'week' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'day' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'hour' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'minute' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'month' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'quarter' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'second' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'year' => 'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction', 'sign' => 'Oro\\ORM\\Query\\AST\\Functions\\Numeric\\Sign', 'pow' => 'Oro\\ORM\\Query\\AST\\Functions\\Numeric\\Pow'))); \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array(require VENDOR_DIR . '/autoload.php', 'loadClass')); $entityManagerConfig = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array(APP_DIR . '/src/Application/Entity'), $app['debug']); $entityManager = Doctrine\ORM\EntityManager::create($app['dbs.options']['default'], $entityManagerConfig); Doctrine\Common\Persistence\PersistentObject::setObjectManager($entityManager); $app['orm.proxies_dir'] = STORAGE_DIR . '/cache/proxy'; $app['orm.manager_registry'] = $app->share(function ($app) { return new \Application\Doctrine\ORM\DoctrineManagerRegistry('manager_registry', array('default' => $app['orm.em']->getConnection()), array('default' => $app['orm.em'])); }); $app['form.extensions'] = $app->share($app->extend('form.extensions', function ($extensions) use($app) { $extensions[] = new \Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension($app['orm.manager_registry']); return $extensions; })); } /***** Validator *****/ $app->register(new \Silex\Provider\ValidatorServiceProvider()); $app['validator.mapping.mapping.file_path'] = APP_DIR . '/configs/validation.yml'; $app['validator.mapping.class_metadata_factory'] = $app->share(function ($app) {
public function register(Pimple\Container $c) { include __DIR__ . '/../local/config.php'; foreach ($env as $envk => $envval) { $c["config/{$envk}"] = $envval; } $c['routes'] = ['/' => 'route/index', '/test', '/index', '/form', '/exception']; $c['entityManager'] = function ($c) { $config = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/orm"), $c['config/devVersion']); $conn = $c['config/databases']['default']; return Doctrine\ORM\EntityManager::create($conn, $config); }; $c['dispatcher'] = function ($c) { $routes = $c['routes']; $dispatcher = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) use($routes) { foreach ($routes as $k => $v) { if (is_int($k)) { $k = $v; $v = "route{$v}"; } $r->addRoute('*', $k, $v); } }); return $dispatcher; }; $c['request'] = function ($c) { $req = Zend\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); $c['logger']->notice('Started ' . $req->getMethod() . ' ' . $req->getUri()->getPath()); return $req; }; $c['resource'] = function ($c) { $dispatcher = $c['dispatcher']; $request = $c['request']; $uri = $request->getUri(); $path = $uri->getPath(); if (preg_match("|^(.+)\\..+\$|", $path, $matches)) { //if path ends in .json, .html, etc, ignore it $path = $matches[1]; } $res = $dispatcher->dispatch('*', $path); if ($res[0] == FastRoute\Dispatcher::NOT_FOUND) { throw new WebAppRouteNotFoundException("Route '{$path}' not found on routing table"); } $reqParameters = $res[2]; $c['requestParameters'] = $reqParameters; $entry = $res[1]; if (!isset($c[$entry])) { throw new WebAppResourceNotFoundException("Resource '{$entry}' not found on DI container"); } $res = $c[$entry]; $c['logger']->notice("Resource Selected ({$entry}): " . get_class($res)); return $res; }; $c['response'] = function ($c) { try { $resource = $c['resource']; return $resource->exec(); } catch (Exception $e) { return $c['handleException']($e); } }; $c['templaterFactory'] = function ($c) { $temp = new ExampleApp\templater\SampleTemplaterFactory(); $temp->globalContext = ['url' => $c['config/publicUrl'], 'assetsUrl' => $c['config/assetsUrl']]; return $temp; }; $c['responseFactory'] = function ($c) { $respFactory = new Resourceful\ResponseFactory(); $respFactory->templaterFactory = $c['templaterFactory']; return $respFactory; }; $c['responseEmitter'] = function ($c) { return new Zend\Diactoros\Response\SapiEmitter(); }; $c['session'] = function ($c) { $sess = new Resourceful\SessionStorage("ExampleApp"); $sess->startSession(); return $sess; }; $c['logger'] = function ($c) { $handler = new Monolog\Handler\ErrorLogHandler(Monolog\Handler\ErrorLogHandler::SAPI, Monolog\Logger::NOTICE); $formatter = new Monolog\Formatter\LineFormatter(); $formatter->includeStacktraces(true); $handler->setFormatter($formatter); $log = new Monolog\Logger('webapp'); $log->pushHandler($handler); return $log; }; $c['handleException'] = $c->protect(function ($e) use($c) { $c['logger']->error($e); $exceptionBuilder = new \Resourceful\Exception\ExceptionResponseBuilder(); $exceptionBuilder->includeStackTrace = $c['config/devVersion']; $exceptionBuilder->responseFactory = $c['responseFactory']; $request = null; try { $request = $c['request']; } catch (Exception $e) { //ignore and just use a null request } $resp = $exceptionBuilder->buildResponse($e, $request); return $resp; }); $mkres = function ($cls) use($c) { return function ($c) use($cls) { $res = new $cls(); $res->request = $c['request']; $res->parameters = $c['requestParameters']; $res->responseFactory = $c['responseFactory']; $res->session = $c['session']; return $res; }; }; $c['route/index'] = $mkres('ExampleApp\\Home\\Control\\IndexResource'); $c['route/form'] = $mkres('ExampleApp\\Home\\Control\\FormResource'); $c['route/exception'] = $mkres('ExampleApp\\Home\\Control\\ExceptionResource'); }
if (is_file(__DIR__ . '/' . $file)) { include $file; return true; } return false; }); //initialize smarty require __DIR__ . '/lib/php/Smarty-3.1.12/libs/Smarty.class.php'; $smarty = new Smarty(); $smarty->setCacheDir("tmp"); $smarty->setCompileDir("tmp"); //initialize doctrine date_default_timezone_set("Europe/Berlin"); // Setup Autoloader (1) require __DIR__ . '/lib/php/DoctrineORM-2.3.0/Doctrine/ORM/Tools/Setup.php'; Doctrine\ORM\Tools\Setup::registerAutoloadDirectory(__DIR__ . "/lib/php/DoctrineORM-2.3.0"); $config = new Doctrine\ORM\Configuration(); // (2) // Proxy Configuration (3) $config->setProxyDir(__DIR__ . '/tmp'); $config->setProxyNamespace('tmp'); $config->setAutoGenerateProxyClasses(true); // Mapping Configuration (4) $driverImpl = $config->newDefaultAnnotationDriver(__DIR__ . "/model"); $config->setMetadataDriverImpl($driverImpl); // Caching Configuration (5) $cache = new \Doctrine\Common\Cache\ArrayCache(); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // database configuration parameters (6) $conn = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/tmp/db.sqlite', 'driverOptions' => array(1002 => 'SET NAMES utf8'));
<?php return [\Doctrine\ORM\EntityManager::class => function (\Domynation\Config\ConfigInterface $config) { $devMode = !IS_PRODUCTION; $config = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($config->get('entityDirectories'), $devMode); if (IS_PRODUCTION) { $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ApcuCache()); $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ApcuCache()); } // Uncomment the following to debug every request made to the DB //$config->setSQLLogger(new Doctrine\DBAL\Logging\EchoSQLLogger); return Doctrine\ORM\EntityManager::create(['driver' => DB_DRIVER, 'dbname' => DB_DATABASE, 'user' => DB_USER, 'password' => DB_PASSWORD], $config); }, \Doctrine\DBAL\Connection::class => function () { $db = \Doctrine\DBAL\DriverManager::getConnection(['driver' => DB_DRIVER, 'dbname' => DB_DATABASE, 'user' => DB_USER, 'password' => DB_PASSWORD], new \Doctrine\DBAL\Configuration()); // @todo: Extremely ugly hack until all the event listeners are refactored. \Event::setDatabase($db); return $db; }, \Domynation\Bus\CommandBusInterface::class => function (\Interop\Container\ContainerInterface $container, \Domynation\Authentication\AuthenticatorInterface $auth, \Domynation\Eventing\EventDispatcherInterface $dispatcher, \Domynation\Cache\CacheInterface $cache) { $busLogger = new Monolog\Logger('Bus_logger'); $busLogger->pushHandler(new Monolog\Handler\StreamHandler(PATH_BASE . '/logs/bus.log', Monolog\Logger::INFO)); return new Domynation\Bus\BasicCommandBus($container, $dispatcher, [new \Domynation\Bus\Middlewares\AuthorizationMiddleware($auth), new \Domynation\Bus\Middlewares\CachingMiddleware($cache), new \Domynation\Bus\Middlewares\LoggingMiddleware($busLogger, $auth), new \Domynation\Bus\Middlewares\HandlingMiddleware()]); }, \Domynation\Http\Router::class => function (\Interop\Container\ContainerInterface $container, \Domynation\Authentication\UserInterface $user) { $routerLogger = new Monolog\Logger('Router_logger'); $routerLogger->pushHandler(new Monolog\Handler\StreamHandler(PATH_BASE . '/logs/router.log', Monolog\Logger::INFO)); return new \Domynation\Http\Router($container, new \Domynation\Http\AuthenticationMiddleware($user), new \Domynation\Http\AuthorizationMiddleware($user), new \Domynation\Http\ValidationMiddleware($container), new \Domynation\Http\LoggingMiddleware($routerLogger, $user), new \Domynation\Http\HandlingMiddleware($container)); }, \Domynation\Cache\CacheInterface::class => function () { switch (CACHE_DRIVER) { case 'redis': return new \Domynation\Cache\RedisCache(REDIS_HOST, REDIS_PORT); default: return new \Domynation\Cache\InMemoryCache();
if (file_exists(PATH_BASEDIR . 'src/hardcodedtextcats/' . key(HelperConfig::$core["lang_available"]) . '.php')) { $HT = (require PATH_BASEDIR . 'src/hardcodedtextcats/' . key(HelperConfig::$core["lang_available"]) . '.php'); } else { $HT = (require PATH_BASEDIR . 'src/hardcodedtextcats/de.php'); } } HardcodedText::init($HT); $serviceManager->setFactory('db', function () { return null; }); if (!HelperConfig::$core['maintenancemode']) { // ---------------------------------------------------------------------------- // Begin database init // ---------------------------------------------------------------------------- $serviceManager->setFactory('entitymanager', function () { $doctrineconfig = Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration([PATH_BASEDIR . "/src"], HelperConfig::$core['debug']); $connectionParams = ['url' => HelperConfig::$secrets['db_type'] . '://' . HelperConfig::$secrets['db_user'] . ':' . HelperConfig::$secrets['db_password'] . '@' . HelperConfig::$secrets['db_server'] . '/' . HelperConfig::$secrets['db_name'], 'charset' => 'UTF8', 'driverOptions' => [\PDO::ATTR_EMULATE_PREPARES => false, \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]]; return Doctrine\ORM\EntityManager::create($connectionParams, $doctrineconfig); }); $serviceManager->setFactory('db', function (ServiceManager $serviceManager) { return $serviceManager->get('entitymanager')->getConnection()->getWrappedConnection(); }); // ---------------------------------------------------------------------------- // more init stuff // ---------------------------------------------------------------------------- $serviceManager->setFactory('textcats', function (ServiceManager $serviceManager) { $langavailable = HelperConfig::$core["lang_available"]; $textcats = new \HaaseIT\Textcat(HelperConfig::$lang, $serviceManager->get('db'), key($langavailable), HelperConfig::$core['textcatsverbose'], PATH_LOGS); $textcats->loadTextcats(); return $textcats; });