forked from Automattic/media-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.service.php
86 lines (69 loc) · 2.55 KB
/
class.service.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
/**
* Abstract service class. Every service should implement this class.
*/
abstract class MEXP_Service {
public $template = null;
/**
* Handles the AJAX request and returns an appropriate response. This should be used, for
* example, to perform an API request to the service provider and return the results.
*
* @param array $request The request parameters.
* @return Response|false|WP_Error A Response object should be returned on success, boolean false should be returned if there are no results to show, and a WP_Error should be returned if there is an error.
*/
abstract function request( array $request );
/**
* Returns an array of custom text labels for this service. See the get_labels() method for default labels.
*
* @return array Associative array of labels.
*/
abstract function labels( array $labels );
/**
* Returns an array of tabs (routers) for the service's media manager panel.
*
* @return array Associative array of tabs. The key is the tab ID and the value is an array of tab attributes.
*/
abstract function tabs( array $tabs );
/**
* A *very* simple dependency system that allows a plugin to return an array of classes and filename that it requires. Currently
* only the OAuth class is available as a dependency.
*
* @return array Associative array of required classes. The array key is the portion of the filename and the value is the class name.
*/
public function requires() {
return array();
}
/**
* Fired when the service is loaded. Allows the service to enqueue JS/CSS only when it's required. Akin to WordPress' load action.
*
* @return null
*/
public function load() {
}
/**
* Sets the template object for this service. Should be called by the child class on initialisation.
*
* @return null
*/
final public function set_template( MEXP_Template $template ) {
$this->template = $template;
}
/**
* Returns the template object for this service.
*
* @return Template|null A Template object, or null if a template isn't set.
*/
final public function get_template() {
return $this->template;
}
}