Metadatas using super class insert
This commit is contained in:
parent
9450512c11
commit
473e268888
|
@ -8,10 +8,10 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
* Representa a entidade Metadata e extende a super classe Entity
|
* Representa a entidade Metadata e extende a super classe Entity
|
||||||
*/
|
*/
|
||||||
class Metadata extends Entity {
|
class Metadata extends Entity {
|
||||||
const POST_TYPE = 'tainacan-metadata';
|
|
||||||
|
|
||||||
use \Tainacan\Traits\Entity_Collection_Relation;
|
use \Tainacan\Traits\Entity_Collection_Relation;
|
||||||
|
|
||||||
|
protected static $post_type = 'tainacan-metadata';
|
||||||
|
|
||||||
function __construct( $which = 0 ) {
|
function __construct( $which = 0 ) {
|
||||||
|
|
||||||
$this->repository = 'Tainacan_Metadatas';
|
$this->repository = 'Tainacan_Metadatas';
|
||||||
|
|
|
@ -9,6 +9,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
* Class Metadatas
|
* Class Metadatas
|
||||||
*/
|
*/
|
||||||
class Metadatas extends Repository {
|
class Metadatas extends Repository {
|
||||||
|
protected $entities_type = '\Tainacan\Entities\Metadata';
|
||||||
|
|
||||||
public function get_map() {
|
public function get_map() {
|
||||||
return [
|
return [
|
||||||
|
@ -113,13 +114,13 @@ class Metadatas extends Repository {
|
||||||
'rewrite' => true,
|
'rewrite' => true,
|
||||||
'capability_type' => 'post',
|
'capability_type' => 'post',
|
||||||
);
|
);
|
||||||
register_post_type(Entities\Metadata::POST_TYPE, $args);
|
register_post_type(Entities\Metadata::get_post_type(), $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Entities\Metadata $metadata
|
* @param Entities\Metadata $metadata
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*
|
||||||
public function insert($metadata) {
|
public function insert($metadata) {
|
||||||
// First iterate through the native post properties
|
// First iterate through the native post properties
|
||||||
$map = $this->get_map();
|
$map = $this->get_map();
|
||||||
|
@ -155,7 +156,7 @@ class Metadatas extends Repository {
|
||||||
|
|
||||||
// return a brand new object
|
// return a brand new object
|
||||||
return new Entities\Metadata($metadata->WP_Post);
|
return new Entities\Metadata($metadata->WP_Post);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public function fetch($object, $args = []){
|
public function fetch($object, $args = []){
|
||||||
// TODO: get metadata from parent collections
|
// TODO: get metadata from parent collections
|
||||||
|
@ -165,7 +166,7 @@ class Metadatas extends Repository {
|
||||||
$collection_id = ( is_object( $object ) ) ? $object->get_id() : $object;
|
$collection_id = ( is_object( $object ) ) ? $object->get_id() : $object;
|
||||||
|
|
||||||
$args = array_merge([
|
$args = array_merge([
|
||||||
'post_type' => Entities\Metadata::POST_TYPE,
|
'post_type' => Entities\Metadata::get_post_type(),
|
||||||
'posts_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
'meta_key' => 'collection_id',
|
'meta_key' => 'collection_id',
|
||||||
|
|
Loading…
Reference in New Issue