Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractRestfulController: return response instead of array #110

Open
finn-matti opened this issue Feb 25, 2022 · 2 comments
Open

AbstractRestfulController: return response instead of array #110

finn-matti opened this issue Feb 25, 2022 · 2 comments

Comments

@finn-matti
Copy link

Feature Request

At the moment all method that map to HTTP verbs return something like the following:

   /**
     * Create a new resource
     *
     * @param  mixed $data
     * @return mixed
     */
    public function create($data)
    {
        $this->response->setStatusCode(405);

        return [
            'content' => 'Method Not Allowed'
        ];
    }

We suggest that the response object should be returned here, instead of an array, like so:

   /**
     * Create a new resource
     *
     * @param  mixed $data
     * @return mixed
     */
    public function create($data)
    {
        $this->response->setStatusCode(405);
        $this->response->setContent('Method Not Allowed');

        return $this->response
    }
Q A
New Feature yes
RFC no
BC Break maybe

Summary

In this way a not implemented method in a controller can simply be left out and Laminas does the right thing automatically.

At the moment you have to overwrite the method no matter what.

@Ocramius
Copy link
Member

In theory, if mixed is allowed as response, it should not be a BC break.

What happens right now if you return a Response instance?

@Ocramius Ocramius added the RFC label Feb 25, 2022
@Ocramius
Copy link
Member

Also: could you write a test for current behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants