Code Duplication    Length = 26-26 lines in 2 locations

core/Field/Association_Field.php 2 locations

@@ 327-352 (lines=26) @@
324
	 *
325
	 * @return array $options
326
	 */
327
	protected function get_user_options( $type ) {
328
		/**
329
		 * Filter the default parameters when fetching users for a particular field.
330
		 *
331
		 * @param array $args The parameters, passed to get_users().
332
		 */
333
		$filter_name = 'carbon_fields_association_field_options_' . $this->get_base_name() . '_' . $type['type'];
334
		$args = apply_filters( $filter_name, array(
335
			'fields' => 'ID',
336
		) );
337
338
		// fetch and prepare users as association items
339
		$users = get_users( $args );
340
		foreach ( $users as &$u ) {
341
			$u = array(
342
				'id' => intval( $u ),
343
				'title' => $this->get_title_by_type( $u, $type['type'] ),
344
				'type' => $type['type'],
345
				'subtype' => 'user',
346
				'label' => $this->get_item_label( $u, $type['type'] ),
347
				'is_trashed' => false,
348
				'edit_link' => $this->get_object_edit_link( $type, $u ),
349
			);
350
		}
351
		return $users;
352
	}
353
354
	/**
355
	 * Get comment options
@@ 359-384 (lines=26) @@
356
	 *
357
	 * @return array $options
358
	 */
359
	protected function get_comment_options( $type ) {
360
		/**
361
		 * Filter the default parameters when fetching comments for a particular field.
362
		 *
363
		 * @param array $args The parameters, passed to get_comments().
364
		 */
365
		$filter_name = 'carbon_fields_association_field_options_' . $this->get_base_name() . '_' . $type['type'];
366
		$args = apply_filters( $filter_name, array(
367
			'fields' => 'ids',
368
		) );
369
370
		// fetch and prepare comments as association items
371
		$comments = get_comments( $args );
372
		foreach ( $comments as &$c ) {
373
			$c = array(
374
				'id' => intval( $c ),
375
				'title' => $this->get_title_by_type( $c, $type['type'] ),
376
				'type' => $type['type'],
377
				'subtype' => 'comment',
378
				'label' => $this->get_item_label( $c, $type['type'] ),
379
				'is_trashed' => false,
380
				'edit_link' => $this->get_object_edit_link( $type, $c ),
381
			);
382
		}
383
		return $comments;
384
	}
385
386
	/**
387
	 * Generate the item options.