Completed
Branch FET-10766-extract-activation-d... (a650cc)
by
unknown
87:01 queued 68:06
created

ChangesIn40834   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setHooks() 0 11 1
A removeResponseHeaders() 0 9 3
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