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

AjaxController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 10 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
}