Skip to content

Commit

Permalink
commit prima di merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gliderShip committed May 24, 2012
1 parent be1b2a9 commit c12e356
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 149 deletions.
185 changes: 92 additions & 93 deletions Controller/TicketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ class TicketController extends Controller
* Lists all Ticket entities.
*
*/
public function indexAction()
public function indexAction($status)
{

$statusId =
$em = $this->getDoctrine()->getEntityManager();

$entities = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->findAll();
$entities = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->findBy(array( Ticket=> $status));

return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:index.html.twig', array(
'entities' => $entities
Expand All @@ -47,17 +49,14 @@ public function showAction($id)
if (!$entity) {
throw $this->createNotFoundException('Unable to find Ticket entity.');
}

$comment = new Comment();
$comment->setCreatedBy(null);
$comment_form = $this->createForm(new CommentType($entity->getId()), $comment);
if( $entity->getState()->getCode() == TicketState::STATE_CLOSED ){
return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:show_closed.html.twig', array(
'entity' => $entity,
));
}
else{

} else{
return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:show_open.html.twig', array(
'entity' => $entity,
'comment_form' => $comment_form->createView()
Expand Down Expand Up @@ -122,86 +121,86 @@ public function createAction()
* Displays a form to edit an existing Ticket entity.
*
*/
public function editAction($id)
{
$em = $this->getDoctrine()->getEntityManager();

$entity = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->find($id);

if (!$entity) {
throw $this->createNotFoundException('Unable to find Ticket entity.');
}

$editForm = $this->createForm(new TicketType(), $entity);
$deleteForm = $this->createDeleteForm($id);

return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}

/**
* Edits an existing Ticket entity.
*
*/
public function updateAction($id)
{
$em = $this->getDoctrine()->getEntityManager();

$entity = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->find($id);

if (!$entity) {
throw $this->createNotFoundException('Unable to find Ticket entity.');
}

$editForm = $this->createForm(new TicketType(), $entity);
$deleteForm = $this->createDeleteForm($id);

$request = $this->getRequest();

$editForm->bindRequest($request);

if ($editForm->isValid()) {
$em->persist($entity);
$em->flush();

return $this->redirect($this->generateUrl('ticket_edit', array('id' => $id)));
}

return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}

/**
* Deletes a Ticket entity.
*
*/
public function deleteAction($id)
{
$form = $this->createDeleteForm($id);
$request = $this->getRequest();

$form->bindRequest($request);

if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->find($id);

if (!$entity) {
throw $this->createNotFoundException('Unable to find Ticket entity.');
}

$em->remove($entity);
$em->flush();
}

return $this->redirect($this->generateUrl('ticket'));
}
// public function editAction($id)
// {
// $em = $this->getDoctrine()->getEntityManager();
//
// $entity = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->find($id);
//
// if (!$entity) {
// throw $this->createNotFoundException('Unable to find Ticket entity.');
// }
//
// $editForm = $this->createForm(new TicketType(), $entity);
// $deleteForm = $this->createDeleteForm($id);
//
// return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:edit.html.twig', array(
// 'entity' => $entity,
// 'edit_form' => $editForm->createView(),
// 'delete_form' => $deleteForm->createView(),
// ));
// }

// /**
// * Edits an existing Ticket entity.
// *
// */
// public function updateAction($id)
// {
// $em = $this->getDoctrine()->getEntityManager();
//
// $entity = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->find($id);
//
// if (!$entity) {
// throw $this->createNotFoundException('Unable to find Ticket entity.');
// }
//
// $editForm = $this->createForm(new TicketType(), $entity);
// $deleteForm = $this->createDeleteForm($id);
//
// $request = $this->getRequest();
//
// $editForm->bindRequest($request);
//
// if ($editForm->isValid()) {
// $em->persist($entity);
// $em->flush();
//
// return $this->redirect($this->generateUrl('ticket_edit', array('id' => $id)));
// }
//
// return $this->render('LiuggioHelpDeskTicketSystemBundle:Ticket:edit.html.twig', array(
// 'entity' => $entity,
// 'edit_form' => $editForm->createView(),
// 'delete_form' => $deleteForm->createView(),
// ));
// }

// /**
// * Deletes a Ticket entity.
// *
// */
// public function deleteAction($id)
// {
// $form = $this->createDeleteForm($id);
// $request = $this->getRequest();
//
// $form->bindRequest($request);
//
// if ($form->isValid()) {
// $em = $this->getDoctrine()->getEntityManager();
// $entity = $em->getRepository('LiuggioHelpDeskTicketSystemBundle:Ticket')->find($id);
//
// if (!$entity) {
// throw $this->createNotFoundException('Unable to find Ticket entity.');
// }
//
// $em->remove($entity);
// $em->flush();
// }
//
// return $this->redirect($this->generateUrl('ticket'));
// }

/**
* Close the Ticket
Expand Down Expand Up @@ -293,11 +292,11 @@ public function rateAction()

}

private function createDeleteForm($id)
{
return $this->createFormBuilder(array('id' => $id))
->add('id', 'hidden')
->getForm()
;
}
// private function createDeleteForm($id)
// {
// return $this->createFormBuilder(array('id' => $id))
// ->add('id', 'hidden')
// ->getForm()
// ;
// }
}
6 changes: 4 additions & 2 deletions Resources/config/routing/ticket.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ticket:
pattern: /
defaults: { _controller: "LiuggioHelpDeskTicketSystemBundle:Ticket:index" }
pattern: /{status}
defaults: { _controller: "LiuggioHelpDeskTicketSystemBundle:Ticket:index", status: open }
requirements:
status: open|closed|all

ticket_show:
pattern: /{id}/show
Expand Down
54 changes: 0 additions & 54 deletions Tests/Controller/CommentController.php

This file was deleted.

0 comments on commit c12e356

Please sign in to comment.