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

WebApiContext::$request and WebApiContext::$response should be protected not private #59

Open
zippy1981 opened this issue Aug 1, 2016 · 2 comments

Comments

@zippy1981
Copy link

If I want to extend that context I need raw access to the request and response object.

@kevin-lot
Copy link

Take a look at this comment.
#66 (comment)

In fact, this repo needs to remove old version of Guzzle compatibility (the one that it doesn't use PSR-7) to change the visibility of this properties.

@DanTalash
Copy link

If you want to get access to the response object without forking this library you can always retrieve it via reflection.

For example, from a sub-class:

protected function getResponse() {
    static $propertyReflection;

    if ($propertyReflection === null) {
        $classReflection    = new ReflectionClass(WebApiContext::class);
        $propertyReflection = $classReflection->getProperty('response');

        $propertyReflection->setAccessible(true);
    }

    return $propertyReflection->getValue($this);
}

You can do something similar to get the request object. This is a bit of a dirty hack, but it gets the result you want.

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

No branches or pull requests

3 participants