Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12518559
D3853.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3853.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D3853: Serialize UserAction classes as array
Attached
Detach File
Event Timeline
Log In to Comment