Created
May 3, 2014 16:58
-
-
Save jippi/247b9219f7c600f60b54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Controller; | |
| use Cake\Event\Event; | |
| class PostsController extends AppController { | |
| public $paginate = ['limit' => 5]; | |
| public function beforeFilter(Event $event) { | |
| $fm = $this | |
| ->Crud | |
| ->listener('view') | |
| ->fields() | |
| ->all($this->Posts) | |
| ->field('is_active') | |
| ->input(['label' => 'Active']) | |
| ->alias('Active') | |
| ->end() | |
| ->field('comment_count') | |
| ->blacklist(); | |
| return parent::beforeFilter($event); | |
| } | |
| public function index() { | |
| $fm = $this->Crud->listener('view')->fields(); | |
| $fm->field('id')->blacklist(); | |
| $this->Crud->on('beforePaginate', function(Event $event) { | |
| $event->subject->object = $this->Posts->find('search', $this->request->query); | |
| }); | |
| return $this->Crud->execute(); | |
| } | |
| public function add() { | |
| return (new \Crud\Action\AddAction($this))->handle(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment