public function quick(Request $req, Response $res) { if (!$req->isPost()) { throw new \Chalk\Exception("Upload action only accepts POST requests"); } $quick = new \Chalk\Core\Model\Url\Quick(); $wrap = $this->em->wrap($quick); $wrap->graphFromArray($req->bodyParams()); if (!$wrap->graphIsValid()) { $this->notify("{$req->info->singular} could not be added, please try again", 'negative'); return $res->redirect($this->url(array('action' => 'index'))); return; } $redirect = new Url($req->redirect); $content = $this->em($req->info)->one(['url' => $quick->url]); if ($content) { $redirect->queryParam('contentNew', $content->id); return $res->redirect($redirect); } $content = $this->em($req->info)->create(); $content->status = \Chalk\App::STATUS_PUBLISHED; $content->fromArray($quick->toArray()); $this->em->persist($content); $this->em->flush(); $redirect->queryParam('contentNew', $content->id); return $res->redirect($redirect); }
public function testQueryParam() { $url = new Url(); $url->queryParam('test', 'OK'); $this->assertEquals('OK', $url->queryParam('test')); }