Skip to content

Instantly share code, notes, and snippets.

View gkalyan's full-sized avatar

Gopi Kalyan gkalyan

View GitHub Profile
@gkalyan
gkalyan / CompanyController.php
Created November 20, 2012 09:07
List Entities Action
public function listEntitiesAction(Request $request)
{
$entity = $request->query->get('entity');
$table = $request->query->get('table');
$repository = $this->getDoctrine()->getRepository('AALCOCompanyBundle:' . $entity);
$metadata = $this->getDoctrine()->getEntityManager()->getClassMetadata('AALCOCompanyBundle:' . $entity);
$qb = $repository->createQueryBuilder($table);
$dataTable = new Datatable(
$request->query->all(),
$repository,
@gkalyan
gkalyan / CompanyController.php
Created October 25, 2012 08:40
Prob deleting users
public function deleteUserAction($id) {
$em = $this->getDoctrine()->getManager();
$parentUser = new User();
$user = $em->getRepository('ACMECompanyBundle:User')->find($id);
$currentUser = $this->get('security.context')->getToken()->getUser();
if ($id == $currentUser->getId()) {
return new Response("You cannot delete the current user");
}