Completed
Push — milestone/2.0 ( 8a1186...26a446 )
by
unknown
04:33
created

REST_API_Service::disabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Carbon_Fields\Service;
4
5
use \Carbon_Fields\REST_API\Router;
6
use \Carbon_Fields\REST_API\Decorator;
7
8
/*
9
 * Service which provides the ability to do meta queries for multi-value fields and nested fields
10
 */
11
class REST_API_Service extends Service {
12
13
	/**
14
	 * Router instance
15
	 * 
16
	 * @var Router
17
	 */
18
	protected $router;
19
20
	/**
21
	 * Decorator instance
22
	 * 
23
	 * @var Decorator
24
	 */
25
	protected $decorator;
26
	
27
	/**
28
	 * @param Router    $router
29
	 * @param Decorator $decorator
30
	 */
31
	public function __construct( Router $router, Decorator $decorator ) {
32
		$this->router = $router;
33
		$this->decorator = $decorator;
34
	}
35
36
	/**
37
	 * Enable REST API integration
38
	 */
39
	protected function enabled() {
40
		add_action( 'carbon_after_register_fields', array( $this, 'boot' ) );
41
	}
42
43
	/**
44
	 * Disable REST API integration
45
	 */
46
	protected function disabled() {
47
		remove_action( 'carbon_after_register_fields', array( $this, 'boot' ) );
48
	}
49
50
	/**
51
	 * Bootstrap all functionality
52
	 */
53
	public function boot() {
54
		$this->router->boot();
55
		$this->decorator->boot();
56
	}
57
}