get('users.username'); $email = $params->get('users.email'); $password = $params->get('users.password'); $command = new RegisterUserCommand($username, $email, $password, $this->actor->getUser()); $this->dispatch($command, $params); // Presumably, the user was created successfully. (The command handler // would have thrown an exception if not.) We set this post as our // document's primary element. $serializer = new UserSerializer; $document = $this->document()->setPrimaryElement($serializer->resource($user)); return $this->respondWithDocument($document, 201); } }