Example #1
0
 public function postEdit(Application $app, Request $request, $id = null)
 {
     $title = 'Post ' . ($id ? 'edit' : 'add');
     $data = $id ? $app['post.model']->find($id) : $app['post.model'];
     $form = $app['form.factory']->createBuilder(new Form\PostType($app), $data)->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $post = $form->getData();
         $post->save();
         return $app->redirect($app->path('post_list'));
     }
     return $app['twig']->render('admin/form.twig', ['title' => $title, 'form' => $form->createView()]);
 }
Example #2
0
 public function indexAction(Application $app)
 {
     return $app->redirect($app->path('demo'));
 }
Example #3
0
 /**
  * Get the path to the application "app" directory.
  *
  * @return string 
  * @static 
  */
 public static function path()
 {
     return \App\Application::path();
 }
Example #4
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use App\Application;
$app = new Application();
$app->init();
if ($app['env'] === 'dev') {
    $app['oauth'] = $app->share(function () use($app) {
        return new \App\OAuthMock($app->path('authorize'));
    });
    $app->run();
}
Example #5
0
 public function logout(Application $app)
 {
     $app->session->clear();
     return $app->redirect($app->path('top'));
 }