Skip to content

Instantly share code, notes, and snippets.

@0GiS0
Last active February 1, 2019 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0GiS0/0eab0dce11d5da554941f56655d775c4 to your computer and use it in GitHub Desktop.
Save 0GiS0/0eab0dce11d5da554941f56655d775c4 to your computer and use it in GitHub Desktop.
<?php
namespace App\Controller;
use App\Service\TableService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class TablesController extends AbstractController
{
/**
* @Route("/", name="tables")
*/
public function index(TableService $table)
{
return $this->render('tables/index.html.twig', [
'controller_name' => 'TablesController',
'entities' => $table->getEntities(),
]);
}
/**
* @Route("/add/entity")
*/
public function create(Request $request, TableService $table)
{
$table->createEntity($request->get('firstName'), $request->get('lastName'));
return $this->redirectToRoute('tables');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment