Beispiel #1
0
 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');
     }
 }
Beispiel #2
0
 public function doIndex()
 {
     $releases = $this->tableManager->getTable('Phpsx\\Website\\Table\\Release')->getAll(0, 1, 'publishedAt', Sql::SORT_DESC);
     $release = current($releases);
     $this->setBody(['links' => [['rel' => 'composer', 'title' => 'Composer', 'href' => 'https://packagist.org/packages/psx/sample', 'description' => 'Sample project which contains a basic API to get started with PSX'], ['rel' => 'vagrant', 'title' => 'Vagrant', 'href' => 'https://github.com/k42b3/psx-vagrant', 'description' => 'Repository which contains a Vagrant-Box with the PSX sample project'], ['rel' => 'download', 'title' => $release['tagName'], 'href' => $release['htmlUrl'], 'description' => 'Latest repository tag']]]);
 }