From c7889eeaa0bbd61b8684b67240a60de2bca02d77 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 26 Jul 2018 10:58:35 -0300 Subject: [PATCH] creating prop semantic_uri to store metadatum schema information --- .../entities/class-tainacan-metadatum.php | 20 ++++++++++++++++++- .../repositories/class-tainacan-metadata.php | 14 ++++++++++++- src/exposers/class-tainacan-exposers.php | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/classes/entities/class-tainacan-metadatum.php b/src/classes/entities/class-tainacan-metadatum.php index 9535e82f3..8b1fd5f6e 100644 --- a/src/classes/entities/class-tainacan-metadatum.php +++ b/src/classes/entities/class-tainacan-metadatum.php @@ -210,6 +210,15 @@ class Metadatum extends Entity { public function get_exposer_mapping() { return $this->get_mapped_property('exposer_mapping'); } + + /** + * Return the semantic_uri + * + * @return string + */ + function get_semantic_uri(){ + return $this->get_mapped_property('semantic_uri'); + } /** * Set the metadatum name @@ -361,7 +370,16 @@ class Metadatum extends Entity { public function set_exposer_mapping( $value ) { $this->set_mapped_property('exposer_mapping', $value); } - + + /** + * Set Semantic URI for the metadatum + * + * @param [string] $value + * @return void + */ + function set_semantic_uri( $value ){ + $this->set_mapped_property('semantic_uri', $value); + } /** * Transient property used to store the status of the metadatum for a particular collection diff --git a/src/classes/repositories/class-tainacan-metadata.php b/src/classes/repositories/class-tainacan-metadata.php index 7341b8f3a..bdeb61da0 100644 --- a/src/classes/repositories/class-tainacan-metadata.php +++ b/src/classes/repositories/class-tainacan-metadata.php @@ -40,6 +40,10 @@ class Metadata extends Repository { } + /** + * {@inheritDoc} + * @see \Tainacan\Repositories\Repository::get_map() + */ public function get_map() { return apply_filters('tainacan-get-map-'.$this->get_name(), [ 'name' => [ @@ -182,7 +186,15 @@ class Metadata extends Repository { 'validation' => v::stringType()->in( [ 'yes', 'no', 'never' ] ), 'description' => __( 'Display by default on listing or do not display or never display.', 'tainacan' ), 'default' => 'yes' - ] + ], + 'semantic_uri' => [ + 'map' => 'meta', + 'title' => __( 'The semantic metadatum description URI' ), + 'type' => __( 'url' ), + 'validation' => v::optional(v::url()), + 'description' => __( 'The semantic metadatum description URI like: ', 'tainacan' ).'https://schema.org/URL', + 'default' => '' + ] ] ); } diff --git a/src/exposers/class-tainacan-exposers.php b/src/exposers/class-tainacan-exposers.php index 3295639e7..e0f30fc58 100644 --- a/src/exposers/class-tainacan-exposers.php +++ b/src/exposers/class-tainacan-exposers.php @@ -403,7 +403,7 @@ class Exposers { $metadatum->set_metadata_type('Tainacan\Metadata_Types\Text'); } $metadatum->set_name($mapper_metadatum['label']); - $metadatum->set_description($mapper_metadatum['URI']); + $metadatum->set_semantic_uri($mapper_metadatum['URI']); $metadatum->set_exposer_mapping([ $mapper->slug => $slug ]);