AjaxController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Class AjaxController
5
 * handle the ajax call to select the sorting and return a json response
6
 */
7
class AjaxController extends Controller
8
{
9
10
    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...
11
        'index'
12
    );
13
14
    /**
15
     * @param SS_HTTPRequest $request
16
     * @return SS_HTTPResponse
17
     */
18
    public function index(SS_HTTPRequest $request)
19
    {
20
        $sortMethod = $request->postVar('type') . 'PopularAddons';
21
        $addons = HomeController::$sortMethod(5);
22
        $body = $this->renderWith('PopularAddons', array('PopularAddons' => $addons));
23
        $response = new SS_HTTPResponse();
24
        $response->addHeader('Content-Type', 'application/json');
25
        $response->setBody(Convert::array2json(array('success' => true, 'body' => $body->getValue())));
26
        return $response;
27
    }
28
}
29