-
Notifications
You must be signed in to change notification settings - Fork 0
Filters
Filters are SECC's form of middle ware. They are classes that are attached to a route and perform logic that returns a boolean value that decides whether the route can be accessed successfully or not.
The recommended way to create a filter is using the LACE interface. Use the command filter make:name
. This will create a new class in the app/models/filters
directory with the specified name and some boiler plate code. All filters need to be under the SECC\Models\Filters
namespace in order to be called.
All filters must contain a main()
method. This method must return a true
or false
value in order to be executed on a route. It may contain any logic you wish to perform prior to executing the route.
To attach a filter to route, open the route's json file and add the "filters"
key. The value must be an array. You can attach as many filters as you want to a route's filters array and all filters will need to return true
before the route is executed. If you want to attach the premade CSRF
filter to a route, your route json file should look like the following...
{
"name": "name",
"path": "path",
"controller": "controller",
"method": "method",
"filters": ["CSRF"]
}
The recommended way to delete a filter is to use LACE. Use the command filter delete:name
. You will of course need to clean up any routes that are making use of the filter. If a route is attempting to call a filter that doesn't exist your application will throw an exception.