Delete filter
This commit is contained in:
parent
43b15b55ba
commit
a2d6c38c13
|
@ -147,7 +147,8 @@ class TAINACAN_REST_Filters_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
public function delete_item_permissions_check( $request ) {
|
||||
return parent::delete_item_permissions_check( $request ); // TODO: Change the autogenerated stub
|
||||
$filter = $this->filter_repository->fetch($request['filter_id']);
|
||||
return $this->filter_repository->can_delete($filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,9 +139,9 @@ class Filters extends Repository {
|
|||
update_post_meta($id, $prop, $metadata->get_mapped_property($prop));
|
||||
} elseif ($mapped['map'] == 'meta_multi') {
|
||||
$values = $metadata->get_mapped_property($prop);
|
||||
|
||||
|
||||
delete_post_meta($id, $prop);
|
||||
|
||||
|
||||
if (is_array($values)){
|
||||
foreach ($values as $value){
|
||||
add_post_meta($id, $prop, $value);
|
||||
|
@ -154,8 +154,17 @@ class Filters extends Repository {
|
|||
return new Entities\Filter($metadata->WP_Post);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
* @return Entities\Filter
|
||||
*
|
||||
*/
|
||||
public function delete($args){
|
||||
if(!empty($args[1]) && $args[1]['is_permanently'] === true){
|
||||
return new Entities\Filter(wp_delete_post($args[0], $args[1]['is_permanently']));
|
||||
}
|
||||
|
||||
return new Entities\Filter(wp_trash_post($args[0]));
|
||||
}
|
||||
|
||||
public function update($object){
|
||||
|
|
|
@ -51,7 +51,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
|||
'collection',
|
||||
array(
|
||||
'name' => 'Collection filtered',
|
||||
'description' => 'Is filtered'
|
||||
'description' => 'Is filtered',
|
||||
),
|
||||
true
|
||||
);
|
||||
|
@ -60,7 +60,7 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
|||
'metadata',
|
||||
array(
|
||||
'name' => 'Metadata filtered',
|
||||
'description' => 'Is filtered'
|
||||
'description' => 'Is filtered',
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -73,13 +73,13 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
|||
'collection' => $collection,
|
||||
'description' => 'descricao',
|
||||
'metadata' => $metadata,
|
||||
'filter_type' => $filter_type
|
||||
'filter_type' => $filter_type,
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
$is_permanently = json_encode([
|
||||
'is_permanently' => true
|
||||
'is_permanently' => false
|
||||
]);
|
||||
|
||||
$request = new \WP_REST_Request(
|
||||
|
@ -91,18 +91,16 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->markTestIncomplete('Incomplete');
|
||||
|
||||
$this->assertEquals('filtro', $data['name']);
|
||||
|
||||
$filter_status = get_post($filter->get_id())->post_status;
|
||||
|
||||
$this->assertEquals('trash', $filter_status);
|
||||
|
||||
##### TRASH #####
|
||||
##### DELETE #####
|
||||
|
||||
$is_permanently = json_encode([
|
||||
'is_permanently' => false
|
||||
'is_permanently' => true
|
||||
]);
|
||||
|
||||
$request = new \WP_REST_Request(
|
||||
|
|
Loading…
Reference in New Issue