daily pastebin goal
6%
SHARE
TWEET

Untitled

vince-db Apr 14th, 2016 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace Application\Cms\Controllers;
  4.  
  5. use Phalcon\Mvc\Model\Criteria;
  6. use Phalcon\Paginator\Adapter\Model as Paginator;
  7. use Application\Cms\Models\Category as Category;
  8.  
  9. class CategoryController extends ControllerBase
  10. {
  11.  
  12.     /**
  13.      * Searches for category
  14.      */
  15.     public function searchAction()
  16.     {
  17.         $numberPage = 1;
  18.         if ($this->request->isPost()) {
  19.             $query = Criteria::fromInput($this->di, 'Category', $_POST);
  20.             exit(var_dump($query));
  21.             $this->persistent->parameters = $query->getParams();
  22.         } else {
  23.             $numberPage = $this->request->getQuery("page", "int");
  24.         }
  25.  
  26.         $parameters = $this->persistent->parameters;
  27.         if (!is_array($parameters)) {
  28.             $parameters = array();
  29.         }
  30.         $parameters["order"] = "id";
  31.  
  32.         $category = Category::find($parameters);
  33.         if (count($category) == 0) {
  34.             $this->flash->notice("The search did not find any category");
  35.  
  36.             $this->dispatcher->forward(array(
  37.                 "controller" => "category",
  38.                 "action" => "index"
  39.             ));
  40.  
  41.             return;
  42.         }
  43.  
  44.         $paginator = new Paginator(array(
  45.             'data' => $category,
  46.             'limit'=> 10,
  47.             'page' => $numberPage
  48.         ));
  49.  
  50.         $this->view->page = $paginator->getPaginate();
  51.     }
  52.  
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top