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

Request API vs IRequest interface #147

Open
xificurk opened this issue Dec 2, 2018 · 4 comments
Open

Request API vs IRequest interface #147

xificurk opened this issue Dec 2, 2018 · 4 comments
Milestone

Comments

@xificurk
Copy link

xificurk commented Dec 2, 2018

Request implements a couple of extra methods that are not defined in IRequest interface. Nette 3 deprecated autowiring of Request type, only autowiring via interface is now supported. This means that those extra methods are basically "inaccessible" for any consumer. I think those methods should be either added to the interface, or deprecated and eventually removed.

  • getReferer(): ?Url - the interface already mentions this method in @method annotation, the annotation should be transformed to a proper method definition.
  • isSameSite(): bool - this should be definitely added to the interface.
  • detectLanguage(array $langs): ?string - this can be easily extracted to a separate service and removed from Request.

What are your thoughts? Shall I send a PR(s)?

Related to #137, #90

@xificurk
Copy link
Author

@dg Any thoughts? I think this needs to be resolved before stable 3.0 version.

@dg
Copy link
Member

dg commented Feb 28, 2019

For the next version there are plans to move to middleware and there will be probably a lot of changes. So currently I do not want make a BC break and we'll solve it the next time.

@dg dg added this to the v4.0 milestone Feb 28, 2019
@xificurk
Copy link
Author

xificurk commented Feb 28, 2019

I really think this needs to be solved now, because of BC break introduced in #90.

Please, tell me if I'm missing some crucial point. The following code works just fine in Nette 2.4.x:

class Foo
{
    /** @var Nette\Http\Request */
    private $request;
 
   public function __construct(Nette\Http\Request $request)
    {
        $this->request = $request;
    }
 
    public function bar(): void
    {
        if ($this->request->isSameSite()) {
            // whatava
        }
    }

As far as I know, there is no way how to make it work in Nette 3.x. I can't use directly Request type and the IRequest interface does not declare isSameSite() method (and bunch of others).

@dg
Copy link
Member

dg commented Mar 9, 2019

I reverted fix for #90.

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

2 participants