Содержание

Symfony YAML Configuration Reference

The filters.yml configuration file

In this article we assume that you are familiar with The YAML Format and Configuration File Principles.

The filters.yml configuration file describes the filter chain to be executed for every request. The main filters.yml configuration file for an application can be found in the apps/APP_NAME/config/ directory.

The filters.yml configuration file contains a list of named filter definitions:

FILTER_1:
  # definition of filter 1
 
FILTER_2:
  # definition of filter 2
 
# ...

When the controller initializes the filter chain for a request, it reads the filters.yml file and registers the filters by looking for the class name of the filter (class) and the parameters (param) used to configure the filter object.

filter_name:
  class:           class_name
  param:           array_of_parameters

Filter configuration options

filter_name

Specifies the name of the filter. By default there are configured four filters: rendering, security, cache and execution. When you override the filters.yml file, you must keep all filters from the inherited configuration file:

rendering: ~
security:  ~
cache:     ~
execution: ~

The filters are executed in the same order as they appear in the configuration file. As symfony executes the filters as a chain, the first registered filter is executed first and last. The rendering filter should always be the first registered filter and the execution filter should be the last one.

The rendering is a mandatory filter and is responsible for the output of the response to the browser.

The security filter checks the security by calling the getCredential() method of the action. Once the credential has been acquired, it verifies that the user has the same credential by calling the hasCredential() method of the user object.

The cache filter manages the caching of actions and pages. It is also responsible for adding the needed HTTP cache headers to the response (Last-Modified, ETag, Cache-Control, Expires, …)

The execution filter a mandatory one. It is at the center of the filter chain and does all action and view execution.

filter_name > class

Specifies the filter class name. This class should extend the sfFilter base class. Here is the list of classes used in default configuration:

filter_name > param

Specifies an array of parameters used to configure the filter object. Some of the filters are identified with the type parameter:

Eg.:

rendering:
  class: sfRenderingFilter
  param:
    type: rendering

</div></body><link id=«apn-null-stylesheet» rel=«stylesheet» href=«chrome-extension:aaaapkhcbchjhhhbhljkcpmldmflnccm/config/skin/css/containers.css»><iframe id=«apn-null-toolbar» src=«./Symfony YAML Configuration Reference filters.yml file_files/toolbar.htm» class=«apn-toolbar SkipThisFixedPosition apn-v5-toolbar» style=«top: 0px;»></iframe><style id=«apn-body-style»>html { padding-top: 34px ! important; border-top: 1px solid transparent; }</style></html>