HQD-104: add asJson method to return JSON response in Action class#345
Conversation
📝 WalkthroughWalkthroughAdded a public ChangesJSON Response Helper
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a JSON response helper to the base hipanel\actions\Action class so action implementations can return JSON responses directly.
Changes:
- Imports
yii\web\Response. - Adds
Action::asJson()to set response format/data and return the response object.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ]); | ||
| } | ||
|
|
||
| public function asJson(array $data = []): Response |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/actions/Action.php (1)
320-327: ⚡ Quick winConsider adding PHPDoc for consistency.
Most other public methods in this class include PHPDoc comments. Consider adding documentation to maintain consistency with the existing code style.
📝 Suggested PHPDoc
+ /** + * Creates a JSON response with the provided data. + * + * `@param` array $data The data to be sent in the response + * `@return` Response The configured response object + */ public function asJson(array $data = []): Response {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/actions/Action.php` around lines 320 - 327, Add a PHPDoc block for the public method asJson(array $data = []): Response to match the rest of the class style; document the method purpose, the parameter $data (array), and the return type Response, and include any relevant tags like `@param` and `@return` above the asJson method that operates on $this->controller->response and sets Response::FORMAT_JSON.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/actions/Action.php`:
- Around line 320-327: Add a PHPDoc block for the public method asJson(array
$data = []): Response to match the rest of the class style; document the method
purpose, the parameter $data (array), and the return type Response, and include
any relevant tags like `@param` and `@return` above the asJson method that operates
on $this->controller->response and sets Response::FORMAT_JSON.
Summary by CodeRabbit