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()]); }
public function indexAction(Application $app) { return $app->redirect($app->path('demo')); }
/** * Get the path to the application "app" directory. * * @return string * @static */ public static function path() { return \App\Application::path(); }
<?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(); }
public function logout(Application $app) { $app->session->clear(); return $app->redirect($app->path('top')); }