Detectors are used by the framework to analyze a request and make quick assertions about the incoming data or petition. CakePHP provides a set of default request detectors, such as post
, ajax
, or ssl
. However, you can easily extend the available detectors using CakeRequest::addDetector()
. There are four different types of detectors that you can create:
Environment Value Comparison: This compares a value from
env()
for equality with the given valuePattern Value Comparison: This compares a value from
env()
with a regular expressionOptions-based Comparison: This uses a list of options to create a regular expression (options will be merged for subsequent calls to add an already defined options-based detector)
Callback: This uses a callable type to handle the comparison (the callback function receives the request object as the first and only argument)
We'll focus on the callback detector here, as it's by far the most powerful.