public function doCategory() { $table = $this->tableManager->getTable('Phpsx\\Website\\Table\\Blog'); $category = $this->getUriFragment('category'); $totalResults = $table->getCount(new Condition(['category', 'LIKE', '%' . $category . '%'])); if ($totalResults > 0) { $selfUrl = $this->reverseRouter->getUrl(__METHOD__, ['category' => $category]); $startIndex = $this->getStartIndex(); $this->setBody(['totalResults' => $totalResults, 'startIndex' => $startIndex, 'entry' => $table->getEntriesByCategory($category, $startIndex), 'links' => $this->getLinks($selfUrl, $startIndex, $totalResults)]); } else { throw new StatusCode\NotFoundException('Category does not exist'); } }
public function doIndex() { $this->setBody(['motd' => 'Welcome, PSX is a framework written in PHP to create REST APIs', 'links' => [['rel' => 'self', 'href' => $this->reverseRouter->getUrl(__CLASS__)], ['rel' => 'download', 'href' => $this->reverseRouter->getUrl('Phpsx\\Website\\Application\\Download::doIndex')], ['rel' => 'documentation', 'href' => $this->reverseRouter->getUrl('Phpsx\\Website\\Application\\Documentation::doIndex')], ['rel' => 'blog', 'href' => $this->reverseRouter->getUrl('Phpsx\\Website\\Application\\Blog::doIndex')]]]); }
public function doIndex() { $this->setBody(['links' => [['rel' => 'manual', 'title' => 'Manual', 'href' => 'http://psx.readthedocs.org', 'description' => 'The official manual of PSX'], ['rel' => 'api', 'title' => 'API', 'href' => $this->reverseRouter->getBasePath() . '/api', 'description' => 'The official API of PSX'], ['rel' => 'coverage', 'title' => 'Test coverage', 'href' => $this->reverseRouter->getBasePath() . '/coverage', 'description' => 'Shows how many code is covered by tests'], ['rel' => 'sample', 'title' => 'Example', 'href' => 'http://example.phpsx.org', 'description' => 'Example REST API and documentation'], ['rel' => 'source', 'title' => 'Github', 'href' => 'https://github.com/k42b3/psx', 'description' => 'The repository of PSX']]]); }