Esempio n. 1
0
 function onRouter(&$router)
 {
     $configAdmin = new Config(require 'config.php');
     $that = $this;
     $router->map(['GET', 'POST'], $configAdmin->get('adminRoute'), function () use($that, $configAdmin) {
         return require_once 'main.php';
     });
 }
Esempio n. 2
0
        return new Parvula\Models\Mappers\UsersMongo($c['mongodb']->users);
    }], 'flatfiles' => ['pages' => function () use($c, $conf) {
        return new Parvula\Models\Mappers\PagesFlatFiles($c['pageRenderer'], _PAGES_, $conf->get('fileExtension'));
    }, 'users' => function () use($c) {
        return new Parvula\Models\Mappers\Users($c['fileParser'], _USERS_ . '/users.php');
    }]];
    if (!isset($mappers[$mapperName])) {
        throw new Exception('Mapper `' . htmlspecialchars($mapperName) . '` does not exists, please edit your settings.');
    }
    return $mappers[$mapperName];
};
$app['config:mapper'] = function (Container $c) {
    $fp = $c['fileParser'];
    $mappersConfig = new Config($fp->read(_CONFIG_ . 'mappers.yml'));
    $mapperName = $mappersConfig->get('mapper');
    $conf = new Config($mappersConfig->get($mapperName));
    $conf->set('mapperName', $mapperName);
    return $conf;
};
// Aliases
$app['pages'] = $app['mappers']['pages'];
$app['users'] = $app['mappers']['users'];
$app['themes'] = function (Container $c) {
    return new Parvula\Models\Mappers\Themes(_THEMES_, $c['fileParser']);
};
$app['theme'] = function (Container $c) {
    if ($c['themes']->has($themeName = $c['config']->get('theme'))) {
        return $c['themes']->read($themeName);
    } else {
        throw new Exception('Theme `' . $themeName . '` does not exists');
    }