Exemplo n.º 1
0
define('HTTP_ROOT', $protocol . $_SERVER['HTTP_HOST']);
define('LOCAL_ROOT', __DIR__);
define('HTTP_MEDIA_DIR', HTTP_ROOT . '/media');
define('LOCAL_MEDIA_DIR', LOCAL_ROOT . '/web/media');
define('CONFIG_FILE', LOCAL_ROOT . '/app/config/parameters.yml');
define('SRC_FOLDER', LOCAL_ROOT . '/src');
// set locale to german
$newLocale = setlocale(LC_TIME, 'de_CH.UTF-8', 'de_CH');
// prevent PHP from sending conflicting cache expiration headers with the HTTP response
session_cache_limiter(false);
session_start();
// enable this for log writing to file
$logWriter = new LogWriter(fopen(__DIR__ . '/app/log/cms.log', 'a'));
$config = \rmatil\cms\Handler\ConfigurationHandler::readConfiguration(CONFIG_FILE);
$app = new Slim(array('debug' => true, 'log.level' => \Slim\Log::DEBUG, 'log.enabled' => true, 'controller.class_prefix' => 'rmatil\\cms\\Controller', 'controller.class_suffix' => 'Controller', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'php', 'log.writer' => $logWriter, 'templates.path' => LOCAL_ROOT . '/web/templates/' . $config[\rmatil\cms\Constants\ConfigurationNames::TEMPLATE][\rmatil\cms\Constants\ConfigurationNames::TEMPLATE_PATH], 'view' => new \Slim\Views\Twig()));
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => __DIR__ . '/app/cache');
$view->parserExtensions = array(new \Slim\Views\TwigExtension(), new \Twig_Extension_Debug());
// Add JMS Serializer to app
$app->container->singleton('serializer', function () {
    $namingStrategy = new \JMS\Serializer\Naming\CamelCaseNamingStrategy();
    return SerializerBuilder::create()->addDefaultDeserializationVisitors()->addDefaultSerializationVisitors()->setSerializationVisitor('json', new \rmatil\cms\Serializer\JsonSerializationVisitor($namingStrategy))->build();
});
HandlerSingleton::setEntityManager($entityManager);
$thumbnailHandler = HandlerSingleton::getThumbnailHandler();
$fileHandler = HandlerSingleton::getFileHandler(HTTP_MEDIA_DIR, LOCAL_MEDIA_DIR);
$registrationHandler = HandlerSingleton::getRegistrationHandler($config['mail']['use']);
$databaseHandler = HandlerSingleton::getDatabaseHandler();
$loginHandler = HandlerSingleton::getLoginHandler(array('^\\/authenticate' => array('ROLE_SUPER_ADMIN', 'ROLE_ANONYMOUS'), '^\\/api\\/.*' => array('ROLE_SUPER_ADMIN')));
// Add Doctrine Entity Manager to app
$app->container->singleton('entityManager', function () use($entityManager) {