コード例 #1
0
 /**
  * /snippets/language-slug[/snippet-slug]
  *
  * @return string
  */
 public function actionIndex()
 {
     $this->parseQueryParams(true);
     // Make sure at least language slug is there
     if (!$this->language) {
         return $this->goHome();
     }
     if ($this->snippet) {
         $this->snippet->updateCounters(['views' => 1]);
         return $this->render('snippet', ['language' => $this->language, 'snippet' => $this->snippet, 'commentModel' => new CommentForm()]);
     } else {
         return $this->render('language', ['language' => $this->language, 'latestSnippets' => LatestSnippets::getTopTen($this->language), 'popularSnippets' => PopularSnippets::getTopTen($this->language)]);
     }
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: jc21/snippets-site
 /**
  * Site Homepage
  *
  * @return string
  */
 public function actionIndex()
 {
     return $this->render('index', ['latestSnippets' => LatestSnippets::getTopTen(), 'popularSnippets' => PopularSnippets::getTopTen()]);
 }