fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Documentation error: Namespaced REST controllers require protected $response #1807

Closed rickmacgillis closed 9 years ago

rickmacgillis commented 9 years ago

When you use namespaced controllers, Controller_Rest does not recognize the $this->response property as valid as it's apparently out of scope when calling it from \Modulename\Controller\Classname. To solve this issue, you must define your namespaced controller a bit differently than what's in the documentation at http://fuelphp.com/docs/general/controllers/rest.html

First create a protected property named $response.

protected $response = null;

Now, in your before() method, set:

$this->response = new \Response;

You can now use the namespaced REST controller normally without the E_NOTICE and other errors.

WanWizard commented 9 years ago

Isn't the issue here that if ( ! $response instanceof Response) should be if ( ! $response instanceof \Response) ?