forked from jadavsushil/GintonicCMS
/
PostsController.php
47 lines (43 loc) · 976 Bytes
/
PostsController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace GintonicCMS\Controller;
use App\Controller\AppController;
/**
* Posts Controller
*
* @property \Posts\Model\Table\PostsTable $Posts
*/
class PostsController extends AppController
{
/**
* Making sure that we use the Posts plugin's model layer
*
* @return void
*/
public function initialize()
{
$this->loadModel('Posts.Posts');
}
/**
* Index method
*
* @return void
*/
public function index()
{
$this->set('posts', $this->paginate($this->Posts));
$this->set('_serialize', ['posts']);
}
/**
* View method
*
* @param string|null $id Post id.
* @return void
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function view($slug)
{
$post = $this->Posts->find('slugged', ['slug' => $slug]);
$this->set('post', $post);
$this->set('_serialize', ['post']);
}
}