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
<?php
namespace hji\construction\core;
use hji\construction\interfaces\IPost;
class PostModel
{
function __construct($dataModel = null)
{
$properties = array(
"ID" => null,
"comment_count" => 0,
"comment_status" => "closed",
"ping_status" => "closed",
"post_author" => 1,
"post_content" => null,
"post_date" => date("c"),
"post_modified" => date("c"),
"post_date_gmt" => gmdate("c"),
"post_modified_gmt" => gmdate("c"),
"post_excerpt" => null,
"post_name" => null,
"post_parent" => 0,
"post_status" => "publish",
"post_title" => null,
"post_type" => 'post',
);
foreach ($properties as $property => $value)
{
$this->$property = $value;
}
if ($dataModel instanceof IPost)
{
$this->ID = $dataModel->getPostId();
$this->post_type = $dataModel->getPostType();
$this->post_name = $dataModel->getPageSlug();
$this->post_title = $dataModel->getPostTitle();
}
}
}