Commit: 78cc4683057efe86d280f0984d72e3e152f48c76

Author: alkemann | Date: 2009-11-19 03:42:48 +0100
refactoring index action for `PastesController`
diff --git a/controllers/PastesController.php b/controllers/PastesController.php index 62ed8e3..ee54a2f 100644 --- a/controllers/PastesController.php +++ b/controllers/PastesController.php @@ -24,14 +24,13 @@ class PastesController extends \lithium\action\Controller { * @return array */ public function index() { - $latest = Paste::find('all', array('conditions'=> array( + $conditions = array('conditions'=> array( 'design' => 'latest', 'view' => 'all', 'limit' => '10', 'descending' => 'true' - ))); + )); + $latest = Paste::find('all', $conditions); if ($latest === null) { - if (PasteView::create('latest')->save()) { - $latest = Paste::find('all', array('conditions'=> array( - 'design' => 'latest', 'view' => 'all', 'limit' => '10', 'descending' => 'true' - ))); + if (PasteView::create()->save()) { + $latest = Paste::find('all', $conditions); } } return compact('latest');