Completed
Branch 2.0.0 (814c19)
by Jimmy
03:05
created

Attachment_Model   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 2
1
<?php
2
/**
3
 * Définition des données des attachements
4
 *
5
 * @author Eoxia <[email protected]>
6
 * @since 1.0.0
7
 * @version 1.0.0
8
 * @copyright 2015-2018
9
 * @package EO_Framework\EO_Model\Model
10
 */
11
12
namespace eoxia;
13
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
if ( ! class_exists( '\eoxia\Attachment_Model' ) ) {
19
20
	/**
21
	 * Définition des données des attachements
22
	 */
23
	class Attachment_Model extends Post_Model {
24
25
		/**
26
		 * Définition du modèle principal des attachements
27
		 *
28
		 * @var array Les champs principaux des attachements
29
		 */
30
		protected $schema = array();
31
32
		/**
33
		 * Défini le schéma de WP_Post de type attachment.
34
		 *
35
		 * @since 0.1.0
36
		 * @version 1.0.0
37
		 *
38
		 * @param array $data       Data.
39
		 * @param mixed $req_method Peut être "GET", "POST", "PUT" ou null.
40
		 */
41
		public function __construct( $data = null, $req_method = null ) {
42
			$this->schema['mime_type'] = array(
43
				'type'    => 'string',
44
				'field'   => 'post_mime_type',
45
				'context' => array( 'GET' ),
46
			);
47
48
			$this->schema['_wp_attached_file'] = array(
49
				'type'      => 'string',
50
				'meta_type' => 'single',
51
				'field'     => '_wp_attached_file',
52
			);
53
54
			$this->schema['taxonomy'] = array(
55
				'type'      => 'array',
56
				'meta_type' => 'multiple',
57
				'child'     => array(
58
					Attachment_Class::g()->get_attached_taxonomy() => array(
59
						'meta_type'  => 'multiple',
60
						'array_type' => 'integer',
61
						'type'       => 'array',
62
					),
63
				),
64
			);
65
66
			parent::__construct( $data, $req_method );
67
		}
68
	}
69
} // End if().
70