예제 #1
0
 /**
  * @testdox An item can be created and modified.
  */
 public function modification()
 {
     $item = new Item(null, $this->testUser);
     $item->save(['title' => 'Test']);
     $this->assertEquals(1, $item->getId());
     $this->assertEquals('Test', $item->getTitle());
     $this->assertEquals(1, $this->db->query("SELECT COUNT(*) FROM `items`")->fetchColumn());
     $item->save(['id' => 1, 'title' => 'Testing Title']);
     $this->assertEquals(1, $item->getId());
     $this->assertEquals('Testing Title', $item->getTitle());
     $this->assertEquals(1, $this->db->query("SELECT COUNT(*) FROM `items`")->fetchColumn());
 }
예제 #2
0
 public function render(Request $request, Response $response, array $args)
 {
     $item = new Item($args['id']);
     $size = isset($args['size']) ? $args['size'] : 'o';
     $version = isset($args['version']) ? $args['version'] : null;
     $cacheFile = $item->getCachePath($size, $version);
     $fileResponse = new BinaryFileResponse($cacheFile);
     $fileResponse->headers->set('Content-Type', 'image/png');
     $fileResponse->setFile($cacheFile);
     $fileResponse->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $item->getTitle() . '.png');
     return $fileResponse;
 }
예제 #3
0
 public function view(Request $request, Response $response, array $args)
 {
     $item = new Item($args['id'], $this->user);
     $template = new \App\Template('view.twig');
     $template->item = $item;
     $template->title = $item->getTitle();
     $template->tags = $item->getTags();
     $template->mime_type = $item->getMimeType();
     $template->itemReadGroup = $item->getReadGroup();
     $template->itemEditGroup = $item->getEditGroup();
     // Return the template.
     $response->setContent($template->render());
     return $response;
 }