-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[5.2] Add PassThroughTrait for middleware #9311
Conversation
|
||
trait PassThroughTrait | ||
{ | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe add an empty array property protected $except = [];
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://php.net/manual/en/language.oop5.traits.php
If a trait defines a property then a class can not define a property with the same name, otherwise an error is issued. It is an E_STRICT if the class definition is compatible (same visibility and initial value) or fatal error otherwise.
Example #12 Conflict Resolution
<?php
trait PropertiesTrait {
public $same = true;
public $different = false;
}
class PropertiesExample {
use PropertiesTrait;
public $same = true; // Strict Standards
public $different = true; // Fatal error
}
?>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @overtrue , maybe I misexplained.
The $except
property should be moved from VerifyCsrfToken
to PassThroughTrait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@overtrue is right on this one, it just going to throw exception by defining the property in both place.
👍 @overtrue ATM I have to extend This trait would really ease up things |
|
||
class VerifyCsrfToken | ||
{ | ||
use PassThroughTrait; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also include it to the others middleware, so that we let this passthrough choice for the other ones, especially the \Illuminate\Session\Middleware\StartSession
one ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will do it.
@lucasmichot Yes, almost all my middleware need the trait. |
Indeed @overtrue Is there something we can do for that - maybe do it a different way - let us know @taylorotwell ? |
Let all the middleware supports exclude some URI.