Completed
Branch BUG-10878-event-spaces-remaini... (def5f8)
by
unknown
65:16 queued 53:59
created

ChangesIn40834::setHooks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php namespace EventEspresso\core\libraries\rest_api\changes;
2
3
use EventEspresso\core\libraries\rest_api\controllers\Base;
4
5
/* 
6
 * The checkin and checkout endpoints were added in 4.8.34, 
7
 * where we just added a response headers
8
 */
9
10
11
12
class ChangesIn40834 extends ChangesInBase
13
{
14
15
    /**
16
     * Adds hooks so requests to 4.8.29 don't have the checkin endpoints
17
     */
18
    public function setHooks()
19
    {
20
        //set a hook to remove the checkout/checkout endpoints if the request
21
        //is for lower than 4.8.33
22
        add_filter(
23
            'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
24
            array($this, 'removeResponseHeaders'),
25
            10,
26
            3
27
        );
28
    }
29
30
31
32
    /**
33
     * Removes the checkin and checkout endpoints from the index for requests
34
     * to api versions lowers than 4.8.33
35
     *
36
     * @param array  $response_headers
37
     * @param Base   $controller
38
     * @param string $requested_version
39
     * @return array like $routes_on_this_version
40
     */
41
    public function removeResponseHeaders($response_headers, $controller, $requested_version)
42
    {
43
        if ($controller instanceof Base
44
            && $this->appliesToVersion($requested_version)
45
        ) {
46
            return array();
47
        }
48
        return $response_headers;
49
    }
50
}
51