Code Duplication    Length = 16-16 lines in 2 locations

mysite/code/controllers/RatingApiController.php 1 location

@@ 90-105 (lines=16) @@
87
     * @param array $data
88
     * @return SS_HTTPResponse
89
     */
90
    protected function formatResponse(array $data)
91
    {
92
        $response = new SS_HTTPResponse();
93
        $response
94
            ->addHeader('Content-Type', 'application/json')
95
            ->setBody(Convert::raw2json($data, JSON_PRETTY_PRINT));
96
97
        // Don't cache anything in dev mode
98
        if (Director::get_environment_type() !== 'dev') {
99
            // Only cache failure messages for one minute, otherwise use the configured cache age
100
            $cacheAge = empty($data['success']) ? 60 : Config::inst()->get(__CLASS__, 'cache_age');
101
            $response->addHeader('Cache-Control', 'max-age=' . $cacheAge);
102
        }
103
104
        return $response;
105
    }
106
}
107

mysite/code/controllers/SupportedAddonsApiController.php 1 location

@@ 32-47 (lines=16) @@
29
     * @param array $data
30
     * @return SS_HTTPResponse
31
     */
32
    protected function formatResponse(array $data)
33
    {
34
        $response = new SS_HTTPResponse();
35
        $response
36
            ->addHeader('Content-Type', 'application/json')
37
            ->setBody(Convert::raw2json($data, JSON_PRETTY_PRINT));
38
39
        // Don't cache anything in dev mode
40
        if (Director::get_environment_type() !== 'dev') {
41
            // Only cache failure messages for one minute, otherwise use the configured cache age
42
            $cacheAge = empty($data['success']) ? 60 : Config::inst()->get(__CLASS__, 'cache_age');
43
            $response->addHeader('Cache-Control', 'max-age=' . $cacheAge);
44
        }
45
46
        return $response;
47
    }
48
}
49