Example #1
0
 /**
  * @param Todo $entity
  */
 public function run(EntityInterface $entity)
 {
     assert($entity instanceof Todo);
     $entity->setStatus(new TodoStatus());
     $this->repository->add($entity);
     $this->entityManager->flush();
 }
 /**
  * @Route()
  * @Method("GET")
  * @Template(":Todo/Search:index.html.twig")
  *
  * @param Request $request
  */
 public function indexAction(Request $request)
 {
     $search = new TodoList();
     $form = $this->formFactory->create('todo_list', $search);
     $form->handleRequest($request);
     /** @var SlidingPagination $pagination */
     $pagination = $this->paginator->paginate($this->todoRepository->getPaginateQuery($search), (int) $request->get('page', 1), 10, ['defaultSortFieldName' => 'a.id', 'defaultSortDirection' => 'desc']);
     return ['pagination' => $pagination];
 }
 /**
  * @Route()
  * @Method("GET")
  * @Template(":Todo/Default:index.html.twig")
  *
  * @param Request $request
  * @return array
  */
 public function indexAction(Request $request)
 {
     // TODO: このダサいifなんとかしたい。。。
     $type = $request->get('type', 1);
     if ($type == 1) {
         $spec = $this->openSpecification;
     } elseif ($type == 2) {
         $spec = $this->closeSpecification;
     } else {
         $spec = null;
         $type = 3;
     }
     /** @var SlidingPagination $pagination */
     $pagination = $this->paginator->paginate($this->todoRepository->getPaginateQuery($spec), (int) $request->get('page', 1), 10, ['defaultSortFieldName' => 'a.id', 'defaultSortDirection' => 'desc']);
     return ['pagination' => $pagination, 'type' => $type];
 }