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) && array_key_exists('fields_mappers', $body) &&
is_array($body['fields_mappers']) && is_array($body['fields_mappers']) &&
count($body['fields_mappers']) > 0 && count($body['fields_mappers']) > 0 &&
array_key_exists('exposer-map', $body) array_key_exists('exposer_map', $body)
) { ) {
$field_mapper = $body['fields_mappers'][0]; $field_mapper = $body['fields_mappers'][0];
$field = \Tainacan\Repositories\Repository::get_entity_by_post($field_mapper['field_id']); $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); $type = self::request_has_type($request);
if( // There are a defined mapper if( // There are a defined mapper
is_array($body) && array_key_exists('exposer-map', $body) && is_array($body) && array_key_exists('exposer_map', $body) &&
$Tainacan_Exposers->has_mapper($body['exposer-map']) $Tainacan_Exposers->has_mapper($body['exposer_map'])
) { ) {
if( if(
$type === false || // do not have a exposer type $type === false || // do not have a exposer type
$type->get_mappers() === true || // the type accept all mappers $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 ( 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); $mapper = $Tainacan_Exposers->check_class_name($body['exposer_map'], true, self::MAPPER_CLASS_PREFIX);
return new $mapper; 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 } 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, name: name,
description: description, description: description,
status: status, status: status,
'exposer-map': mapper 'exposer_map': mapper
}) })
.then( res => { .then( res => {
commit('setCollection', { name: name, description: description, status: status, mapper: mapper }); 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) => { return new Promise((resolve, reject) => {
axios.tainacan.post('/field-mappers', { axios.tainacan.post('/field-mappers', {
fields_mappers: fieldsMapperMetadata, fields_mappers: fieldsMapperMetadata,
"exposer-map": mapper "exposer_map": mapper
}).then((res) => { }).then((res) => {
resolve(res.data); resolve(res.data);
}) })

View File

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

View File

@ -79,7 +79,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$this->assertEquals('TestValues_exposers', $data['value']); $this->assertEquals('TestValues_exposers', $data['value']);
$item_exposer_json = json_encode([ $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 = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->field->get_id() );
$request->set_body($item_exposer_json); $request->set_body($item_exposer_json);
@ -137,7 +137,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$this->assertInstanceOf('SimpleXMLElement', @simplexml_load_string($data)); $this->assertInstanceOf('SimpleXMLElement', @simplexml_load_string($data));
$item_exposer_json = json_encode([ $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 = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->field->get_id() );
$request->set_body($item_exposer_json); $request->set_body($item_exposer_json);
@ -148,7 +148,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([ $item_exposer_json = json_encode([
'exposer-type' => 'Xml', '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 = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' );
$request->set_body($item_exposer_json); $request->set_body($item_exposer_json);
@ -190,7 +190,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$this->assertEquals('TestValues_exposers_slug', $data['value']); $this->assertEquals('TestValues_exposers_slug', $data['value']);
$item_exposer_json = json_encode([ $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 = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata/'. $this->field->get_id() );
$request->set_body($item_exposer_json); $request->set_body($item_exposer_json);
@ -201,7 +201,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([ $item_exposer_json = json_encode([
'exposer-type' => 'xml', '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 = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' );
$request->set_body($item_exposer_json); $request->set_body($item_exposer_json);
@ -251,7 +251,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
$item_exposer_json = json_encode([ $item_exposer_json = json_encode([
'exposer-type' => 'Html', 'exposer-type' => 'Html',
'exposer-map' => 'Value' 'exposer_map' => 'Value'
]); ]);
$request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' ); $request = new \WP_REST_Request('GET', $this->namespace . '/item/' . $this->item->get_id() . '/metadata' );
$request->set_body($item_exposer_json); $request->set_body($item_exposer_json);
@ -383,7 +383,7 @@ class TAINACAN_REST_Exposers extends TAINACAN_UnitApiTestCase {
); );
$item_exposer_json = json_encode([ $item_exposer_json = json_encode([
'exposer-map' => 'Value', 'exposer_map' => 'Value',
]); ]);
$request = new \WP_REST_Request('GET', $this->namespace . '/items/' . $this->item->get_id() ); $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() { public function test_mapped_new_collection() {
$collection_JSON = json_encode([ $collection_JSON = json_encode([
'exposer-map' => 'Dublin Core', 'exposer_map' => 'Dublin Core',
'name' => 'TesteJsonAddDublin_Core', 'name' => 'TesteJsonAddDublin_Core',
'description' => 'Teste JSON Dublin Core mapped', 'description' => 'Teste JSON Dublin Core mapped',
'status' => 'publish' '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' => $field->get_id(), 'mapper_metadata' => 'contributor'],
['field_id' => $field2->get_id(), 'mapper_metadata' => 'coverage'] ['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_request->set_body($field_mapper_json);
$field_mapper_response = $this->server->dispatch($field_mapper_request); $field_mapper_response = $this->server->dispatch($field_mapper_request);