refactoring exposer-map to exposer_map to be compatible with vue axios post

This commit is contained in:
Jacson Passold 2018-06-11 21:13:35 -03:00
parent d9cca58d2e
commit 55a758387f
7 changed files with 17 additions and 17 deletions

View File

@ -104,7 +104,7 @@ class REST_Field_Mappers_Controller extends REST_Controller {
array_key_exists('fields_mappers', $body) &&
is_array($body['fields_mappers']) &&
count($body['fields_mappers']) > 0 &&
array_key_exists('exposer-map', $body)
array_key_exists('exposer_map', $body)
) {
$field_mapper = $body['fields_mappers'][0];
$field = \Tainacan\Repositories\Repository::get_entity_by_post($field_mapper['field_id']);

View File

@ -248,14 +248,14 @@ class Exposers {
$type = self::request_has_type($request);
if( // There are a defined mapper
is_array($body) && array_key_exists('exposer-map', $body) &&
$Tainacan_Exposers->has_mapper($body['exposer-map'])
is_array($body) && array_key_exists('exposer_map', $body) &&
$Tainacan_Exposers->has_mapper($body['exposer_map'])
) {
if(
$type === false || // do not have a exposer type
$type->get_mappers() === true || // the type accept all mappers
( is_array($type->get_mappers()) && in_array($body['exposer-map'], $type->get_mappers()) ) ) { // the current mapper is accepted by type
$mapper = $Tainacan_Exposers->check_class_name($body['exposer-map'], true, self::MAPPER_CLASS_PREFIX);
( is_array($type->get_mappers()) && in_array($body['exposer_map'], $type->get_mappers()) ) ) { // the current mapper is accepted by type
$mapper = $Tainacan_Exposers->check_class_name($body['exposer_map'], true, self::MAPPER_CLASS_PREFIX);
return new $mapper;
}
} elseif( is_object($type) && is_array($type->get_mappers()) && count($type->get_mappers()) > 0 ) { //there are no defined mapper, let use the first one o list if has a list

View File

@ -180,7 +180,7 @@ export const sendCollection = ( { commit }, { name, description, status, mapper
name: name,
description: description,
status: status,
'exposer-map': mapper
'exposer_map': mapper
})
.then( res => {
commit('setCollection', { name: name, description: description, status: status, mapper: mapper });

View File

@ -149,7 +149,7 @@ export const updateFieldsMapperMetadata = ({ dispatch }, fieldsMapperMetadata, m
return new Promise((resolve, reject) => {
axios.tainacan.post('/field-mappers', {
fields_mappers: fieldsMapperMetadata,
"exposer-map": mapper
"exposer_map": mapper
}).then((res) => {
resolve(res.data);
})

View File

@ -102,7 +102,7 @@ class TAINACAN_REST_Export_Controller extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([
'exposer-type' => 'Xml',
'exposer-map' => 'Value',
'exposer_map' => 'Value',
'export-background' => false
]);

View File

@ -79,7 +79,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$this->assertEquals('TestValues_exposers', $data['value']);
$item_exposer_json = json_encode([
'exposer-map' => 'Value',
'exposer_map' => 'Value',
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->field->get_id() );
$request->set_body($item_exposer_json);
@ -137,7 +137,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$this->assertInstanceOf('SimpleXMLElement', @simplexml_load_string($data));
$item_exposer_json = json_encode([
'exposer-map' => 'Dublin Core',
'exposer_map' => 'Dublin Core',
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->field->get_id() );
$request->set_body($item_exposer_json);
@ -148,7 +148,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([
'exposer-type' => 'Xml',
'exposer-map' => 'Dublin Core',
'exposer_map' => 'Dublin Core',
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' );
$request->set_body($item_exposer_json);
@ -190,7 +190,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$this->assertEquals('TestValues_exposers_slug', $data['value']);
$item_exposer_json = json_encode([
'exposer-map' => 'dublin-core',
'exposer_map' => 'dublin-core',
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->field->get_id() );
$request->set_body($item_exposer_json);
@ -201,7 +201,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([
'exposer-type' => 'xml',
'exposer-map' => 'dublin-core',
'exposer_map' => 'dublin-core',
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' );
$request->set_body($item_exposer_json);
@ -251,7 +251,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([
'exposer-type' => 'Html',
'exposer-map' => 'Value'
'exposer_map' => 'Value'
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' );
$request->set_body($item_exposer_json);
@ -383,7 +383,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
);
$item_exposer_json = json_encode([
'exposer-map' => 'Value',
'exposer_map' => 'Value',
]);
$request = new \WP_REST_Request('GET', $this->namespace . '/items/' . $this->item->get_id() );
@ -402,7 +402,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
*/
public function test_mapped_new_collection() {
$collection_JSON = json_encode([
'exposer-map' => 'Dublin Core',
'exposer_map' => 'Dublin Core',
'name' => 'TesteJsonAddDublin_Core',
'description' => 'Teste JSON Dublin Core mapped',
'status' => 'publish'

View File

@ -100,7 +100,7 @@ class TAINACAN_REST_Field_Mappers_Controller extends TAINACAN_UnitApiTestCase {
['field_id' => $field->get_id(), 'mapper_metadata' => 'contributor'],
['field_id' => $field2->get_id(), 'mapper_metadata' => 'coverage']
],
'exposer-map' => $dc->slug
'exposer_map' => $dc->slug
]);
$field_mapper_request->set_body($field_mapper_json);
$field_mapper_response = $this->server->dispatch($field_mapper_request);