예제 #1
0
 public function testDoChangeDateUpdate()
 {
     $date = (new \DateTime())->modify('+100 seconds');
     $this->storage->setDateUpdate($date);
     $this->storage->doChangeDateUpdate();
     $this->assertInstanceOf('\\DateTime', $this->storage->getDateUpdate());
     $this->assertNotEquals($date, $this->storage->getDateUpdate());
 }
예제 #2
0
 /**
  * Change storage.
  *
  * @param Storage $storage
  * @param Request $request
  *
  * @return Response
  */
 public function changeAction(Storage $storage, Request $request)
 {
     $response = $this->getCacheTimeKeeper()->getResponse($storage->getDateUpdate());
     // response was not modified for this request
     if ($response->isNotModified($request)) {
         return $response;
     }
     /* @var $form Form */
     $form = $this->createForm(new StorageForm(), $storage);
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $em->persist($storage);
             $em->flush();
             return $this->redirect($this->generateUrl('storage_list'));
         }
     }
     return $this->render('AnimeDbCatalogBundle:Storage:change.html.twig', ['storage' => $storage, 'form' => $form->createView()], $response);
 }