mirror of
https://github.com/typemill/typemill.git
synced 2025-08-06 14:16:46 +02:00
finished TOC feature
This commit is contained in:
@@ -27,33 +27,6 @@ $app = new \Slim\App($settings);
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
/************************
|
||||
* LOAD TWIG VIEW *
|
||||
************************/
|
||||
|
||||
$container['view'] = function ($container) use ($settings){
|
||||
$path = array($settings['settings']['themePath'], $settings['settings']['authorPath']);
|
||||
|
||||
$view = new \Slim\Views\Twig( $path, [
|
||||
'cache' => false,
|
||||
'autoescape' => false
|
||||
]);
|
||||
|
||||
// Instantiate and add Slim specific extension
|
||||
$basePath = rtrim(str_ireplace('index.php', '', $container['request']->getUri()->getBasePath()), '/');
|
||||
$view->addExtension(new Slim\Views\TwigExtension($container['router'], $basePath));
|
||||
|
||||
return $view;
|
||||
};
|
||||
|
||||
/************************
|
||||
* LOAD FLASH MESSAGES *
|
||||
************************/
|
||||
|
||||
$container['flash'] = function () {
|
||||
return new \Slim\Flash\Messages();
|
||||
};
|
||||
|
||||
/****************************
|
||||
* CREATE EVENT DISPATCHER *
|
||||
****************************/
|
||||
@@ -71,18 +44,69 @@ $routes = $middleware = array();
|
||||
foreach($pluginClassNames as $pluginClassName)
|
||||
{
|
||||
$routes = $plugins->getNewRoutes($pluginClassName, $routes);
|
||||
$middleware[] = $plugins->getNewMiddleware($pluginClassName);
|
||||
$middleware = $plugins->getNewMiddleware($pluginClassName, $middleware);
|
||||
|
||||
$dispatcher->addSubscriber(new $pluginClassName($container, $app));
|
||||
}
|
||||
|
||||
$dispatcher->dispatch('onPluginsInitialized');
|
||||
|
||||
/******************************
|
||||
* ADD DISPATCHER TO CONTAINER *
|
||||
******************************/
|
||||
|
||||
$container['dispatcher'] = function($container) use ($dispatcher)
|
||||
{
|
||||
return $dispatcher;
|
||||
};
|
||||
|
||||
/******************************
|
||||
* ADD FLASH MESSAGES FOR TIWG *
|
||||
******************************/
|
||||
|
||||
$container['flash'] = function ()
|
||||
{
|
||||
return new \Slim\Flash\Messages();
|
||||
};
|
||||
|
||||
/********************************
|
||||
* ADD ASSET-FUNCTION FOR TWIG *
|
||||
********************************/
|
||||
|
||||
$container['assets'] = function($c)
|
||||
{
|
||||
return new \Typemill\Assets($c['request']->getUri()->getBaseUrl());
|
||||
};
|
||||
|
||||
/************************
|
||||
* LOAD TWIG VIEW *
|
||||
************************/
|
||||
|
||||
$container['view'] = function ($container) use ($settings)
|
||||
{
|
||||
$path = array($settings['settings']['themePath'], $settings['settings']['authorPath']);
|
||||
|
||||
$view = new \Slim\Views\Twig( $path, [
|
||||
'cache' => false,
|
||||
'autoescape' => false
|
||||
]);
|
||||
|
||||
// Instantiate and add Slim specific extension
|
||||
$basePath = rtrim(str_ireplace('index.php', '', $container['request']->getUri()->getBasePath()), '/');
|
||||
$view->addExtension(new Slim\Views\TwigExtension($container['router'], $basePath));
|
||||
$view['baseUrl'] = $container['request']->getUri()->getBaseUrl();
|
||||
|
||||
/* add flash messages to all views */
|
||||
$view->getEnvironment()->addGlobal('flash', $container->flash);
|
||||
|
||||
/* add asset-function to all views */
|
||||
$view->getEnvironment()->addGlobal('assets', $container->assets);
|
||||
|
||||
return $view;
|
||||
};
|
||||
|
||||
$container->dispatcher->dispatch('onTwigLoaded');
|
||||
|
||||
/************************
|
||||
* ADD MIDDLEWARE *
|
||||
************************/
|
||||
@@ -96,7 +120,5 @@ $container['notFoundHandler'] = function($c)
|
||||
* ADD ROUTES *
|
||||
************************/
|
||||
|
||||
$timer['before router']=microtime(true);
|
||||
|
||||
require __DIR__ . '/Routes/api.php';
|
||||
require __DIR__ . '/Routes/web.php';
|
||||
require __DIR__ . '/Routes/web.php';
|
Reference in New Issue
Block a user