Completed
Pull Request — master (#147)
by Simon
10:31
created

AjaxController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: simon
5
 * Date: 04-Jan-17
6
 * Time: 21:28
7
 */
8
9
10
class AjaxController extends Controller
11
{
12
13
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
14
        'index'
15
    );
16
17
    public function index(SS_HTTPRequest $request)
18
    {
19
        $sortMethod = $request->postVar('type') . 'PopularAddons';
20
        $addons = HomeController::$sortMethod(5);
21
        $body = $this->renderWith('PopularAddons', array('PopularAddons' => $addons));
22
        $response = new SS_HTTPResponse();
23
        $response->addHeader('Content-Type', 'application/json');
24
        $response->setBody(Convert::array2json(array('success' => true, 'body' => $body->getValue())));
25
        return $response;
26
    }
27
28
}