Skip to content

Commit

Permalink
Possibility to delete plugin data (#17)
Browse files Browse the repository at this point in the history
* Possibility to delete plugin data

* Update Removable.php
  • Loading branch information
LuukvH authored and amiracruceru committed Nov 22, 2018
1 parent 5527fc5 commit 0660745
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function patch( $url, $body ) {
* @throws ApiException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function delete( $url, $body ) {
public function delete( $url, $body = null ) {
try {
$request = $this->createRequestNoJson( 'DELETE', $this->formatUrl( $url, 'delete' ), $body );
$response = $this->client()->send( $request );
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/Plugins/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Eduframe\Resources\Plugins;

use Eduframe\Resource;
use Eduframe\Traits\Removable;
use Eduframe\Traits\Storable;

class Data extends Resource {

use Storable;
use Storable, Removable;

/**
* @var array
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasPluginData.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function get_plugin_data_value( $title ) {
* @param $name
* @return mixed
*/
private function get_plugin_data( $title ) {
public function get_plugin_data( $title ) {
$results = array_filter( $this->plugin_data, function ( $plugin_data ) use ( $title ) {
return ( $plugin_data->field->title === $title );
} );
Expand Down
21 changes: 21 additions & 0 deletions src/Traits/Removable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Eduframe\Traits;

/**
* Class Removable
* @package Eduframe\Traits
*/
trait Removable {

use BaseTrait;

/**
* @return mixed
* @throws \Eduframe\Exceptions\ApiException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function delete() {
return $this->connection()->delete( $this->getEndpoint() . '/' . urlencode( $this->id ) );
}
}

0 comments on commit 0660745

Please sign in to comment.