Page MenuHomeDevCentral

D3853.diff
No OneTemporary

D3853.diff

diff --git a/workspaces/src/Engines/Auth/Actions/AddToGroupUserAction.php b/workspaces/src/Engines/Auth/Actions/AddToGroupUserAction.php
--- a/workspaces/src/Engines/Auth/Actions/AddToGroupUserAction.php
+++ b/workspaces/src/Engines/Auth/Actions/AddToGroupUserAction.php
@@ -22,13 +22,14 @@
use Waystone\Workspaces\Engines\Serialization\ArrayDeserializable;
use Exception;
+use JsonSerializable;
use UserGroup;
/**
* User action to add a user into a group
*/
-class AddToGroupUserAction extends UserAction implements ArrayDeserializable {
+class AddToGroupUserAction extends UserAction implements ArrayDeserializable, JsonSerializable {
/**
* @var UserGroup The group to add the user to
@@ -73,4 +74,11 @@
return $instance;
}
+
+ public function jsonSerialize () : array {
+ return [
+ "code" => $this->group->code,
+ "isAdmin" => $this->isAdmin
+ ];
+ }
}
diff --git a/workspaces/src/Engines/Auth/Actions/GivePermissionUserAction.php b/workspaces/src/Engines/Auth/Actions/GivePermissionUserAction.php
--- a/workspaces/src/Engines/Auth/Actions/GivePermissionUserAction.php
+++ b/workspaces/src/Engines/Auth/Actions/GivePermissionUserAction.php
@@ -119,16 +119,21 @@
* Serializes the object to a value that can be serialized natively by
* json_encode().
*
- * @return object The serializable value
+ * @return array The serializable value
*/
- public function jsonSerialize () {
- //TODO: if you wish strict code here, we need such a class.
- $data->resource->type =
- Permission::getResourceTypeCodeFromLetter($this->resourceType);
- $data->resource->id = $this->resourceIdentifier;
- $data->permission->name = $this->permissionName;
- $data->permission->flag = $this->permissionFlag;
-
- return $data;
+ public function jsonSerialize () : array {
+ $type = Permission::getResourceTypeCodeFromLetter($this->resourceType);
+
+ return [
+ "resource" => [
+ "type" => $type,
+ "id" => $this->resourceIdentifier
+ ],
+
+ "permission" => [
+ "name" => $this->permissionName,
+ "flag" => $this->permissionFlag,
+ ],
+ ];
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 10, 09:35 (10 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3151972
Default Alt Text
D3853.diff (2 KB)

Event Timeline