Example #1
0
<?php

// Bootstrapping (i.e. configurations, create framework object etc.)
require __DIR__ . '/config_with_app.php';
// Creating a controller service for comments
$di->set('CommentController', function () use($di) {
    $controller = new Phpmvc\Comment\CommentController();
    $controller->setDI($di);
    return $controller;
});
// Creating a model service for comments
$di->set('comments', function () use($di) {
    $comments = new \Phpmvc\Comment\CommentsInSession();
    $comments->setDI($di);
    $comments->setContext($di->request->getCurrentUrl());
    return $comments;
});
// Defining routes
$app->router->add('', function () use($app) {
    $app->theme->setTitle('Lite om mig');
    $app->views->add('me/page', ['content' => $app->textFilter->doFilter($app->fileContent->get('about.md'), 'shortcode, markdown'), 'byline' => $app->textFilter->doFilter($app->fileContent->get('byline.md'), 'shortcode, markdown')]);
    // Adds the possibility to post comments on the page
    \mife\Comment\CommentSetup::initComments($app);
});
$app->router->add('redovisning/kmom1', function () use($app) {
    $app->theme->setTitle('Redovisning');
    $app->views->add('me/page', ['content' => $app->textFilter->doFilter($app->fileContent->get('kmom1.md'), 'shortcode, markdown'), 'byline' => $app->textFilter->doFilter($app->fileContent->get('byline.md'), 'shortcode, markdown')]);
    // Adds the possibility to post comments on the page
    \mife\Comment\CommentSetup::initComments($app);
});
$app->router->add('redovisning/kmom2', function () use($app) {
Example #2
0
 * This is a Anax pagecontroller.
 *
 */
// Include the essential settings.
require __DIR__ . '/config.php';
// Create services and inject into the app.
$di = new \Anax\DI\CDIFactoryDefault();
$di->set('CommentController', function () use($di) {
    $controller = new Phpmvc\Comment\CommentController();
    $controller->setDI($di);
    return $controller;
});
$di->set('comments', function () use($di) {
    $comments = new \Phpmvc\Comment\CommentsInSession();
    $comments->setDI($di);
    $comments->setContext($di->url->create(''));
    return $comments;
});
//Test
echo 'BaseUrl: ' . $di->request->getBaseUrl() . '<br>';
echo 'SiteUrl: ' . $di->request->getSiteUrl() . '<br>';
echo 'Route: ' . $di->request->getRoute() . '<br>';
echo 'CurrentUrl: ' . $di->request->getCurrentUrl() . '<br>';
echo 'Url-asset: ' . $di->url->asset('kommentarssida') . '<br>';
echo 'Url-create: ' . $di->url->create('');
$app = new \Anax\Kernel\CAnax($di);
// Home route
$app->router->add('', function () use($app) {
    $app->theme->setTitle("Welcome to Anax Guestbook");
    $app->views->add('comment/index');
    $app->theme->addStylesheet('css/comments.css');