Completed
Pull Request — develop (#1698)
by
unknown
01:52
created
src/modules/dashboard/includes/Post_Entity_Match/Query_Builder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
 		global $wpdb;
62 62
 
63 63
 		// If a value has been provided and it's either 'draft' or 'publish', we add the related filter.
64
-		if ( is_string( $this->params['post_status'] ) && in_array(
64
+		if (is_string($this->params['post_status']) && in_array(
65 65
 			$this->params['post_status'],
66 66
 			array(
67 67
 				'publish',
68 68
 				'draft',
69 69
 			),
70 70
 			true
71
-		) ) {
71
+		)) {
72 72
 
73
-			$this->sql .= $wpdb->prepare( ' AND p.post_status = %s', $this->params['post_status'] );
73
+			$this->sql .= $wpdb->prepare(' AND p.post_status = %s', $this->params['post_status']);
74 74
 
75 75
 			return $this;
76 76
 		}
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 	public function post_type() {
85 85
 		$post_types = $this->params['post_types'];
86 86
 
87
-		if ( ! isset( $post_types ) ) {
87
+		if ( ! isset($post_types)) {
88 88
 			return $this;
89 89
 		}
90
-		$post_types_sql = Escape::sql_array( $post_types );
90
+		$post_types_sql = Escape::sql_array($post_types);
91 91
 		$this->sql     .= " AND p.post_type IN ({$post_types_sql}) ";
92 92
 
93 93
 		return $this;
Please login to merge, or discard this patch.
src/modules/dashboard/includes/Post_Entity_Match/Sort.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@
 block discarded – undo
17 17
 	 * @return string
18 18
 	 */
19 19
 	public function get_field_name() {
20
-		$tmp_sort_field_name = substr( $this->sort, 1 );
21
-		if ( 'id' === $tmp_sort_field_name ) {
20
+		$tmp_sort_field_name = substr($this->sort, 1);
21
+		if ('id' === $tmp_sort_field_name) {
22 22
 			return 'p.ID';
23
-		} elseif ( 'date_modified_gmt' === $tmp_sort_field_name ) {
23
+		} elseif ('date_modified_gmt' === $tmp_sort_field_name) {
24 24
 			return 'p.post_modified_gmt';
25 25
 		} else {
26 26
 			return 'p.post_title';
Please login to merge, or discard this patch.
dashboard/includes/Term_Entity_Match/Term_Entity_Match_Rest_Controller.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param $match_service
30 30
 	 */
31
-	public function __construct( $match_service ) {
31
+	public function __construct($match_service) {
32 32
 		$this->match_service = $match_service;
33 33
 	}
34 34
 
35 35
 	public function register_hooks() {
36
-		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
36
+		add_action('rest_api_init', array($this, 'register_routes'));
37 37
 	}
38 38
 
39 39
 	/**
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 			'/term-matches',
47 47
 			array(
48 48
 				'methods'             => 'GET',
49
-				'callback'            => array( $this, 'get_term_matches' ),
49
+				'callback'            => array($this, 'get_term_matches'),
50 50
 				'args'                => array(
51 51
 					'cursor'                   => array(
52 52
 						'type'              => 'string',
53 53
 						'default'           => Cursor::EMPTY_CURSOR_AS_BASE64_STRING,
54 54
 						'validate_callback' => 'rest_validate_request_arg',
55
-						'sanitize_callback' => array( Cursor::class, 'rest_sanitize_request_arg' ),
55
+						'sanitize_callback' => array(Cursor::class, 'rest_sanitize_request_arg'),
56 56
 					),
57 57
 					'limit'                    => array(
58 58
 						'type'              => 'integer',
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 						'validate_callback' => 'rest_validate_request_arg',
91 91
 					),
92 92
 				),
93
-				'permission_callback' => function () {
94
-					return current_user_can( 'manage_options' );
93
+				'permission_callback' => function() {
94
+					return current_user_can('manage_options');
95 95
 				},
96 96
 			)
97 97
 		);
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 			'/term-matches/(?P<term_id>\d+)/matches',
103 103
 			array(
104 104
 				'methods'             => 'POST',
105
-				'callback'            => array( $this, 'create_term_match' ),
105
+				'callback'            => array($this, 'create_term_match'),
106 106
 				'args'                => array(
107 107
 					'term_id' => array(
108 108
 						'required'          => true,
109 109
 						'validate_callback' => 'rest_validate_request_arg',
110 110
 					),
111 111
 				),
112
-				'permission_callback' => function () {
113
-					return current_user_can( 'manage_options' );
112
+				'permission_callback' => function() {
113
+					return current_user_can('manage_options');
114 114
 				},
115 115
 			)
116 116
 		);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			'/term-matches/(?P<term_id>\d+)/matches/(?P<match_id>\d+)',
122 122
 			array(
123 123
 				'methods'             => 'PUT',
124
-				'callback'            => array( $this, 'update_term_match' ),
124
+				'callback'            => array($this, 'update_term_match'),
125 125
 				'args'                => array(
126 126
 					'term_id'  => array(
127 127
 						'required'          => true,
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 						'validate_callback' => 'rest_validate_request_arg',
133 133
 					),
134 134
 				),
135
-				'permission_callback' => function () {
136
-					return current_user_can( 'manage_options' );
135
+				'permission_callback' => function() {
136
+					return current_user_can('manage_options');
137 137
 				},
138 138
 			)
139 139
 		);
@@ -146,27 +146,27 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @throws \Exception If there was a problem getting the match.
148 148
 	 */
149
-	public function get_term_matches( $request ) {
149
+	public function get_term_matches($request) {
150 150
 
151
-		$cursor = $request->get_param( 'cursor' );
152
-		if ( $request->has_param( 'limit' ) ) {
153
-			$cursor['limit'] = $request->get_param( 'limit' );
151
+		$cursor = $request->get_param('cursor');
152
+		if ($request->has_param('limit')) {
153
+			$cursor['limit'] = $request->get_param('limit');
154 154
 		}
155
-		if ( $request->has_param( 'sort' ) ) {
156
-			$cursor['sort'] = $request->get_param( 'sort' );
155
+		if ($request->has_param('sort')) {
156
+			$cursor['sort'] = $request->get_param('sort');
157 157
 		}
158
-		if ( $request->has_param( 'taxonomies' ) ) {
159
-			$cursor['query']['taxonomies'] = $request->get_param( 'taxonomies' );
158
+		if ($request->has_param('taxonomies')) {
159
+			$cursor['query']['taxonomies'] = $request->get_param('taxonomies');
160 160
 		}
161
-		if ( $request->has_param( 'has_match' ) ) {
162
-			$cursor['query']['has_match'] = $request->get_param( 'has_match' );
161
+		if ($request->has_param('has_match')) {
162
+			$cursor['query']['has_match'] = $request->get_param('has_match');
163 163
 		}
164
-		if ( $request->has_param( 'ingredient_name_contains' ) ) {
165
-			$cursor['query']['ingredient_name_contains'] = $request->get_param( 'ingredient_name_contains' );
164
+		if ($request->has_param('ingredient_name_contains')) {
165
+			$cursor['query']['ingredient_name_contains'] = $request->get_param('ingredient_name_contains');
166 166
 		}
167 167
 
168 168
 		// Query.
169
-		$taxonomies = isset( $cursor['query']['taxonomies'] ) ? $cursor['query']['taxonomies'] : apply_filters(
169
+		$taxonomies = isset($cursor['query']['taxonomies']) ? $cursor['query']['taxonomies'] : apply_filters(
170 170
 			'wl_dashboard__post_entity_match__taxonomies',
171 171
 			array(
172 172
 				'post_tag',
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 			)
175 175
 		);
176 176
 
177
-		$has_match                = isset( $cursor['query']['has_match'] ) ? $cursor['query']['has_match'] : null;
178
-		$ingredient_name_contains = isset( $cursor['query']['ingredient_name_contains'] ) ? $cursor['query']['ingredient_name_contains'] : null;
177
+		$has_match                = isset($cursor['query']['has_match']) ? $cursor['query']['has_match'] : null;
178
+		$ingredient_name_contains = isset($cursor['query']['ingredient_name_contains']) ? $cursor['query']['ingredient_name_contains'] : null;
179 179
 
180 180
 		$items = $this->match_service->list_items(
181 181
 			array(
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @throws \Exception If there was a problem creating the match.
213 213
 	 */
214
-	public function create_term_match( $request ) {
214
+	public function create_term_match($request) {
215 215
 
216
-		$term_id = $request->get_param( 'term_id' );
216
+		$term_id = $request->get_param('term_id');
217 217
 
218 218
 		// If we dont have a entry on the match table, then add one.
219
-		$content_id = Wordpress_Content_Id::create_term( $term_id );
220
-		if ( ! Wordpress_Content_Service::get_instance()->get_entity_id( $content_id ) ) {
221
-			$uri = Entity_Uri_Generator::create_uri( $content_id->get_type(), $content_id->get_id() );
222
-			Wordpress_Content_Service::get_instance()->set_entity_id( $content_id, $uri );
219
+		$content_id = Wordpress_Content_Id::create_term($term_id);
220
+		if ( ! Wordpress_Content_Service::get_instance()->get_entity_id($content_id)) {
221
+			$uri = Entity_Uri_Generator::create_uri($content_id->get_type(), $content_id->get_id());
222
+			Wordpress_Content_Service::get_instance()->set_entity_id($content_id, $uri);
223 223
 		}
224 224
 
225 225
 		$match_id = $this->match_service->get_id(
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @throws \Exception If there was a problem updating the match.
246 246
 	 */
247
-	public function update_term_match( $request ) {
247
+	public function update_term_match($request) {
248 248
 		return $this->match_service->set_jsonld(
249
-			$request->get_param( 'term_id' ),
249
+			$request->get_param('term_id'),
250 250
 			Object_Type_Enum::TERM,
251
-			$request->get_param( 'match_id' ),
251
+			$request->get_param('match_id'),
252 252
 			$request->get_json_params()
253 253
 		);
254 254
 	}
Please login to merge, or discard this patch.
modules/dashboard/includes/Term_Entity_Match/Term_Entity_Match_Service.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @throws \Exception If there was a problem generating the list items.
23 23
 	 */
24
-	public function list_items( $args ) {
24
+	public function list_items($args) {
25 25
 		global $wpdb;
26 26
 
27 27
 		$params = wp_parse_args(
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
 		/**
43 43
 		 * @var $sort Sort
44 44
 		 */
45
-		$sort = new Sort( $params['sort'] );
45
+		$sort = new Sort($params['sort']);
46 46
 
47 47
 		$query_builder = new Query_Builder(
48 48
 			$params,
49 49
 			$sort
50 50
 		);
51
-		$query         = $query_builder
51
+		$query = $query_builder
52 52
 			->get();
53 53
 
54 54
 		$items = $wpdb->get_results(
55 55
 		// Each function above is preparing `$sql` by using `$wpdb->prepare`.
56 56
 		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
57
-			$wpdb->prepare( $query, Object_Type_Enum::TERM )
57
+			$wpdb->prepare($query, Object_Type_Enum::TERM)
58 58
 		);
59 59
 
60
-		$sort->apply( $items );
60
+		$sort->apply($items);
61 61
 
62
-		return $this->map( $items );
62
+		return $this->map($items);
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return array
71 71
 	 */
72
-	private function map( array $items ) {
72
+	private function map(array $items) {
73 73
 		return array_map(
74
-			function ( $item ) {
75
-				$data              = json_decode( $item->match_jsonld, true );
76
-				$item->match_name  = $data && is_array( $data ) && array_key_exists( 'name', $data ) ? $data['name'] : null;
77
-				$item->occurrences = $this->get_term_occurrences( $item->id );
74
+			function($item) {
75
+				$data              = json_decode($item->match_jsonld, true);
76
+				$item->match_name  = $data && is_array($data) && array_key_exists('name', $data) ? $data['name'] : null;
77
+				$item->occurrences = $this->get_term_occurrences($item->id);
78 78
 
79 79
 				return $item;
80 80
 			},
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return int
91 91
 	 */
92
-	private function get_term_occurrences( $term_id ) {
93
-		$term = get_term( $term_id );
92
+	private function get_term_occurrences($term_id) {
93
+		$term = get_term($term_id);
94 94
 
95
-		if ( ! is_wp_error( $term ) ) {
95
+		if ( ! is_wp_error($term)) {
96 96
 			return $term->count;
97 97
 		}
98 98
 
Please login to merge, or discard this patch.
src/modules/dashboard/includes/Term_Entity_Match/Query_Builder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	public function taxonomy() {
54 54
 		$taxonomies = $this->params['taxonomies'];
55 55
 
56
-		if ( ! isset( $taxonomies ) ) {
56
+		if ( ! isset($taxonomies)) {
57 57
 			return $this;
58 58
 		}
59
-		$sql        = Escape::sql_array( $taxonomies );
59
+		$sql        = Escape::sql_array($taxonomies);
60 60
 		$this->sql .= " AND tt.taxonomy IN ($sql)";
61 61
 
62 62
 		return $this;
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 		global $wpdb;
72 72
 
73 73
 		// If the ingredient_name_contains value is a non-empty string, add the filter
74
-		if ( is_string( $this->params['ingredient_name_contains'] ) && ! empty( $this->params['ingredient_name_contains'] ) ) {
74
+		if (is_string($this->params['ingredient_name_contains']) && ! empty($this->params['ingredient_name_contains'])) {
75 75
 			$ingredient_name_contains = $this->params['ingredient_name_contains'];
76
-			$this->sql               .= $wpdb->prepare( ' AND t.name LIKE %s', '%' . $ingredient_name_contains . '%' );
76
+			$this->sql               .= $wpdb->prepare(' AND t.name LIKE %s', '%'.$ingredient_name_contains.'%');
77 77
 		}
78 78
 
79 79
 		return $this;
Please login to merge, or discard this patch.
modules/dashboard/includes/Post_Entity_Match/Post_Entity_Match_Service.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @throws \Exception If there was a problem generating the list items.
23 23
 	 */
24
-	public function list_items( $args ) {
24
+	public function list_items($args) {
25 25
 		global $wpdb;
26 26
 
27 27
 		$params = wp_parse_args(
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		/**
41 41
 		 * @var $sort Sort
42 42
 		 */
43
-		$sort = new Sort( $params['sort'] );
43
+		$sort = new Sort($params['sort']);
44 44
 
45 45
 		$query_builder = new Query_Builder(
46 46
 			$params,
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		$items = $wpdb->get_results(
51 51
 		// Each function above is preparing `$sql` by using `$wpdb->prepare`.
52 52
 		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
53
-			$wpdb->prepare( $query_builder->get(), Object_Type_Enum::POST )
53
+			$wpdb->prepare($query_builder->get(), Object_Type_Enum::POST)
54 54
 		);
55 55
 
56
-		$sort->apply( $items );
56
+		$sort->apply($items);
57 57
 
58
-		return $this->map( $items );
58
+		return $this->map($items);
59 59
 	}
60 60
 
61 61
 	/**
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return array
80 80
 	 */
81
-	private function map( array $items ) {
81
+	private function map(array $items) {
82 82
 		return array_map(
83
-			function ( $item ) {
84
-				$data             = json_decode( $item->match_jsonld, true );
85
-				$item->match_name = $data && is_array( $data ) && array_key_exists( 'name', $data ) ? $data['name'] : null;
83
+			function($item) {
84
+				$data             = json_decode($item->match_jsonld, true);
85
+				$item->match_name = $data && is_array($data) && array_key_exists('name', $data) ? $data['name'] : null;
86 86
 
87
-				if ( $item->id ) {
88
-					$item->post_link    = get_edit_post_link( $item->id, 'ui' );
89
-					$item->view_link    = get_permalink( $item->id );
90
-					$item->preview_link = get_preview_post_link( $item->id );
87
+				if ($item->id) {
88
+					$item->post_link    = get_edit_post_link($item->id, 'ui');
89
+					$item->view_link    = get_permalink($item->id);
90
+					$item->preview_link = get_preview_post_link($item->id);
91 91
 				}
92 92
 
93
-				if ( $item->parent_post_id ) {
94
-					$item->parent_post_link = get_edit_post_link( $item->parent_post_id, 'ui' );
93
+				if ($item->parent_post_id) {
94
+					$item->parent_post_link = get_edit_post_link($item->parent_post_id, 'ui');
95 95
 				}
96 96
 
97 97
 				return $item;
Please login to merge, or discard this patch.
src/modules/dashboard/includes/Term_Entity_Match/Sort.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@
 block discarded – undo
17 17
 	 * @return string|null
18 18
 	 */
19 19
 	public function get_field_name() {
20
-		$tmp_sort_field_name = substr( $this->sort, 1 );
21
-		if ( 'id' === $tmp_sort_field_name ) {
20
+		$tmp_sort_field_name = substr($this->sort, 1);
21
+		if ('id' === $tmp_sort_field_name) {
22 22
 			return 't.term_id';
23
-		} elseif ( 'ingredient_term' === $tmp_sort_field_name ) {
23
+		} elseif ('ingredient_term' === $tmp_sort_field_name) {
24 24
 			return 't.name';
25
-		} elseif ( 'matched_ingredient' === $tmp_sort_field_name ) {
25
+		} elseif ('matched_ingredient' === $tmp_sort_field_name) {
26 26
 			return 't.match_name';
27
-		} elseif ( 'occurrences' === $tmp_sort_field_name ) {
27
+		} elseif ('occurrences' === $tmp_sort_field_name) {
28 28
 			// @todo This block will be filled in the future when occurrences handling is implemented
29 29
 			return null;
30 30
 		}
Please login to merge, or discard this patch.
dashboard/includes/Post_Entity_Match/Post_Entity_Match_Rest_Controller.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param Post_Entity_Match_Service $match_service
29 29
 	 */
30
-	public function __construct( $match_service ) {
30
+	public function __construct($match_service) {
31 31
 		$this->match_service = $match_service;
32 32
 	}
33 33
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * Register hooks.
36 36
 	 */
37 37
 	public function register_hooks() {
38
-		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
38
+		add_action('rest_api_init', array($this, 'register_routes'));
39 39
 	}
40 40
 
41 41
 	/**
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 			'/post-matches',
50 50
 			array(
51 51
 				'methods'             => 'GET',
52
-				'callback'            => array( $this, 'get_post_matches' ),
52
+				'callback'            => array($this, 'get_post_matches'),
53 53
 				'args'                => array(
54 54
 					'cursor'      => array(
55 55
 						'type'              => 'string',
56 56
 						'default'           => Cursor::EMPTY_CURSOR_AS_BASE64_STRING,
57 57
 						'validate_callback' => 'rest_validate_request_arg',
58
-						'sanitize_callback' => array( Cursor::class, 'rest_sanitize_request_arg' ),
58
+						'sanitize_callback' => array(Cursor::class, 'rest_sanitize_request_arg'),
59 59
 					),
60 60
 					'limit'       => array(
61 61
 						'type'              => 'integer',
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
 					'post_status' => array(
78 78
 						'type'              => 'string',
79 79
 						'required'          => false,
80
-						'enum'              => array( 'publish', 'draft' ),
80
+						'enum'              => array('publish', 'draft'),
81 81
 						'validate_callback' => 'rest_validate_request_arg',
82 82
 					),
83 83
 					'sort'        => array(
84 84
 						'type'              => 'string',
85 85
 						'required'          => false,
86
-						'enum'              => array( '+date_modified_gmt', '-date_modified_gmt' ),
86
+						'enum'              => array('+date_modified_gmt', '-date_modified_gmt'),
87 87
 						'validate_callback' => 'rest_validate_request_arg',
88 88
 						'default'           => '+date_modified_gmt',
89 89
 					),
90 90
 				),
91
-				'permission_callback' => function () {
92
-					return current_user_can( 'manage_options' );
91
+				'permission_callback' => function() {
92
+					return current_user_can('manage_options');
93 93
 				},
94 94
 			)
95 95
 		);
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			'/post-matches/(?P<post_id>\d+)/matches',
101 101
 			array(
102 102
 				'methods'             => 'POST',
103
-				'callback'            => array( $this, 'create_post_match' ),
103
+				'callback'            => array($this, 'create_post_match'),
104 104
 				'args'                => array(
105 105
 					'post_id' => array(
106 106
 						'required'          => true,
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 						'type'              => 'integer',
109 109
 					),
110 110
 				),
111
-				'permission_callback' => function () {
112
-					return current_user_can( 'manage_options' );
111
+				'permission_callback' => function() {
112
+					return current_user_can('manage_options');
113 113
 				},
114 114
 			)
115 115
 		);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			'/post-matches/(?P<post_id>\d+)/matches/(?P<match_id>\d+)',
121 121
 			array(
122 122
 				'methods'             => 'PUT',
123
-				'callback'            => array( $this, 'update_post_match' ),
123
+				'callback'            => array($this, 'update_post_match'),
124 124
 				'args'                => array(
125 125
 					'post_id'  => array(
126 126
 						'required'          => true,
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 						'type'              => 'integer',
134 134
 					),
135 135
 				),
136
-				'permission_callback' => function () {
136
+				'permission_callback' => function() {
137 137
 
138
-					return current_user_can( 'manage_options' );
138
+					return current_user_can('manage_options');
139 139
 				},
140 140
 			)
141 141
 		);
@@ -146,36 +146,36 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @var $request \WP_REST_Request
148 148
 	 */
149
-	public function get_post_matches( $request ) {
149
+	public function get_post_matches($request) {
150 150
 
151
-		$cursor = $request->get_param( 'cursor' );
152
-		if ( $request->has_param( 'limit' ) ) {
153
-			$cursor['limit'] = $request->get_param( 'limit' );
151
+		$cursor = $request->get_param('cursor');
152
+		if ($request->has_param('limit')) {
153
+			$cursor['limit'] = $request->get_param('limit');
154 154
 		}
155
-		if ( $request->has_param( 'sort' ) ) {
156
-			$cursor['sort'] = $request->get_param( 'sort' );
155
+		if ($request->has_param('sort')) {
156
+			$cursor['sort'] = $request->get_param('sort');
157 157
 		}
158
-		if ( $request->has_param( 'post_types' ) ) {
159
-			$cursor['query']['post_types'] = $request->get_param( 'post_types' );
158
+		if ($request->has_param('post_types')) {
159
+			$cursor['query']['post_types'] = $request->get_param('post_types');
160 160
 		}
161
-		if ( $request->has_param( 'has_match' ) ) {
162
-			$cursor['query']['has_match'] = $request->get_param( 'has_match' );
161
+		if ($request->has_param('has_match')) {
162
+			$cursor['query']['has_match'] = $request->get_param('has_match');
163 163
 		}
164
-		if ( $request->has_param( 'post_status' ) ) {
165
-			$cursor['query']['post_status'] = $request->get_param( 'post_status' );
164
+		if ($request->has_param('post_status')) {
165
+			$cursor['query']['post_status'] = $request->get_param('post_status');
166 166
 		}
167 167
 
168 168
 		// Query.
169
-		$post_types = isset( $cursor['query']['post_types'] ) ? $cursor['query']['post_types'] : apply_filters(
169
+		$post_types = isset($cursor['query']['post_types']) ? $cursor['query']['post_types'] : apply_filters(
170 170
 			'wl_dashboard__post_entity_match__post_types',
171 171
 			array(
172 172
 				'post',
173 173
 				'page',
174 174
 			)
175 175
 		);
176
-		$has_match  = isset( $cursor['query']['has_match'] ) ? $cursor['query']['has_match'] : null;
176
+		$has_match = isset($cursor['query']['has_match']) ? $cursor['query']['has_match'] : null;
177 177
 
178
-		$post_status = isset( $cursor['query']['post_status'] ) ? $cursor['query']['post_status'] : null;
178
+		$post_status = isset($cursor['query']['post_status']) ? $cursor['query']['post_status'] : null;
179 179
 
180 180
 		$items = $this->match_service->list_items(
181 181
 			array(
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @throws \Exception If there was a problem creating the match.
213 213
 	 */
214
-	public function create_post_match( $request ) {
215
-		$post_id = $request->get_param( 'post_id' );
214
+	public function create_post_match($request) {
215
+		$post_id = $request->get_param('post_id');
216 216
 
217 217
 		// If we dont have a entry on the match table, then add one.
218
-		$content_id = Wordpress_Content_Id::create_post( $post_id );
219
-		if ( ! Wordpress_Content_Service::get_instance()->get_entity_id( $content_id ) ) {
220
-			$uri = Entity_Uri_Generator::create_uri( $content_id->get_type(), $content_id->get_id() );
221
-			Wordpress_Content_Service::get_instance()->set_entity_id( $content_id, $uri );
218
+		$content_id = Wordpress_Content_Id::create_post($post_id);
219
+		if ( ! Wordpress_Content_Service::get_instance()->get_entity_id($content_id)) {
220
+			$uri = Entity_Uri_Generator::create_uri($content_id->get_type(), $content_id->get_id());
221
+			Wordpress_Content_Service::get_instance()->set_entity_id($content_id, $uri);
222 222
 		}
223 223
 
224 224
 		$match_id = $this->match_service->get_id(
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @throws \Exception If there was a problem updating the match.
245 245
 	 */
246
-	public function update_post_match( $request ) {
246
+	public function update_post_match($request) {
247 247
 
248 248
 		return $this->match_service->set_jsonld(
249
-			$request->get_param( 'post_id' ),
249
+			$request->get_param('post_id'),
250 250
 			Object_Type_Enum::POST,
251
-			$request->get_param( 'match_id' ),
251
+			$request->get_param('match_id'),
252 252
 			$request->get_json_params()
253 253
 		);
254 254
 	}
Please login to merge, or discard this patch.
src/modules/dashboard/includes/Synchronization/Rest_Controller.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @param Synchronization_Service $synchronization_service
17 17
 	 */
18
-	public function __construct( $synchronization_service ) {
18
+	public function __construct($synchronization_service) {
19 19
 		$this->synchronization_service = $synchronization_service;
20 20
 	}
21 21
 
22 22
 	public function register_hooks() {
23
-		add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
23
+		add_action('rest_api_init', array($this, 'rest_api_init'));
24 24
 	}
25 25
 
26 26
 	public function rest_api_init() {
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			'/synchronizations',
30 30
 			array(
31 31
 				'methods'             => 'POST',
32
-				'callback'            => array( $this, 'create_sync' ),
32
+				'callback'            => array($this, 'create_sync'),
33 33
 				'permission_callback' => '__return_true',
34 34
 			)
35 35
 		);
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 			'/synchronizations',
40 40
 			array(
41 41
 				'methods'             => 'GET',
42
-				'callback'            => array( $this, 'list_syncs' ),
42
+				'callback'            => array($this, 'list_syncs'),
43 43
 				'permission_callback' => '__return_true',
44 44
 				'args'                => array(
45 45
 					'is_running' => array(
46
-						'description' => esc_html__( 'Filter the is_running', 'wordlift' ),
46
+						'description' => esc_html__('Filter the is_running', 'wordlift'),
47 47
 						'type'        => 'boolean',
48 48
 					),
49 49
 				),
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			'/synchronizations',
56 56
 			array(
57 57
 				'methods'             => 'DELETE',
58
-				'callback'            => array( $this, 'delete_syncs' ),
58
+				'callback'            => array($this, 'delete_syncs'),
59 59
 				'permission_callback' => '__return_true',
60 60
 			)
61 61
 		);
@@ -63,27 +63,27 @@  discard block
 block discarded – undo
63 63
 
64 64
 	public function create_sync() {
65 65
 		try {
66
-			return rest_ensure_response( $this->synchronization_service->create() );
67
-		} catch ( \Exception $e ) {
66
+			return rest_ensure_response($this->synchronization_service->create());
67
+		} catch (\Exception $e) {
68 68
 			return new \WP_Error(
69 69
 				'wl_error_synchronization_running',
70
-				esc_html__( 'Another synchronization is already running.', 'wordlift' ),
71
-				array( 'status' => 409 )
70
+				esc_html__('Another synchronization is already running.', 'wordlift'),
71
+				array('status' => 409)
72 72
 			);
73 73
 		}
74 74
 	}
75 75
 
76
-	public function list_syncs( WP_REST_Request $request ) {
76
+	public function list_syncs(WP_REST_Request $request) {
77 77
 		$last_synchronization = $this->synchronization_service->load();
78
-		$is_running_all       = ! $request->has_param( 'is_running' );
79
-		if ( is_a( $last_synchronization, 'Wordlift\Modules\Dashboard\Synchronization\Synchronization' )
80
-			&& ( $is_running_all || $request->get_param( 'is_running' ) === $last_synchronization->is_running() ) ) {
81
-			$data = array( $last_synchronization );
78
+		$is_running_all       = ! $request->has_param('is_running');
79
+		if (is_a($last_synchronization, 'Wordlift\Modules\Dashboard\Synchronization\Synchronization')
80
+			&& ($is_running_all || $request->get_param('is_running') === $last_synchronization->is_running())) {
81
+			$data = array($last_synchronization);
82 82
 		} else {
83 83
 			$data = array();
84 84
 		}
85 85
 
86
-		return rest_ensure_response( array( 'items' => $data ) );
86
+		return rest_ensure_response(array('items' => $data));
87 87
 	}
88 88
 
89 89
 	public function delete_syncs() {
Please login to merge, or discard this patch.