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

Post_Model   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 104
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1
1
<?php
2
/**
3
 * Définition des données des posts
4
 *
5
 * @author Eoxia <[email protected]>
6
 * @since 0.1.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\Post_Model' ) ) {
19
	/**
20
	 * Définition des données des posts
21
	 */
22
	class Post_Model extends Data_Class {
23
24
		/**
25
		 * Définition du modèle principal des posts
26
		 *
27
		 * @var array Les champs principaux des posts
28
		 */
29
		protected $schema = array();
30
31
		/**
32
		 * Défini le schéma de WP_Post.
33
		 *
34
		 * @since 0.1.0
35
		 * @version 1.0.0
36
		 *
37
		 * @param array $data       Data.
38
		 * @param mixed $req_method Peut être "GET", "POST", "PUT" ou null.
39
		 */
40
		public function __construct( $data = null, $req_method = null ) {
41
			$this->schema['id'] = array(
42
				'type'    => 'integer',
43
				'field'   => 'ID',
44
				'default' => 0,
45
			);
46
47
			$this->schema['parent_id'] = array(
48
				'type'  => 'integer',
49
				'field' => 'post_parent',
50
			);
51
52
			$this->schema['author_id'] = array(
53
				'type'  => 'integer',
54
				'field' => 'post_author',
55
			);
56
57
			$this->schema['date'] = array(
58
				'type'    => 'wpeo_date',
59
				'field'   => 'post_date',
60
				'context' => array( 'GET' ),
61
			);
62
63
			$this->schema['date_modified'] = array(
64
				'type'    => 'wpeo_date',
65
				'field'   => 'post_modified',
66
				'context' => array( 'GET' ),
67
			);
68
69
			$this->schema['title'] = array(
70
				'type'    => 'string',
71
				'field'   => 'post_title',
72
				'default' => '',
73
			);
74
75
			$this->schema['slug'] = array(
76
				'type'  => 'string',
77
				'field' => 'post_name',
78
			);
79
80
			$this->schema['content'] = array(
81
				'type'  => 'string',
82
				'field' => 'post_content',
83
			);
84
85
			$this->schema['status'] = array(
86
				'type'    => 'string',
87
				'field'   => 'post_status',
88
				'default' => 'publish',
89
			);
90
91
			$this->schema['link'] = array(
92
				'type'  => 'string',
93
				'field' => 'guid',
94
			);
95
96
			$this->schema['type'] = array(
97
				'type'  => 'string',
98
				'field' => 'post_type',
99
			);
100
101
			$this->schema['order'] = array(
102
				'type'  => 'integer',
103
				'field' => 'menu_order',
104
			);
105
106
			$this->schema['comment_status'] = array(
107
				'type'  => 'string',
108
				'field' => 'comment_status',
109
			);
110
111
			$this->schema['comment_count'] = array(
112
				'type'  => 'string',
113
				'field' => 'comment_count',
114
			);
115
116
			$this->schema['thumbnail_id'] = array(
117
				'type'      => 'integer',
118
				'meta_type' => 'single',
119
				'field'     => '_thumbnail_id',
120
				'default'   => 0,
121
			);
122
123
			parent::__construct( $data, $req_method );
124
		}
125
	}
126
} // End if().
127