Cakephp Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19|Last
Lessons:-Controllers

Accessing path information
CakeRequest also provides useful information about the paths in your application.
CakeRequest::$base and CakeRequest::$webroot are useful for generating urls, and
determining whether or not your application is in a subdirectory.Inspecting the request
Detecting various request conditions used to require using RequestHandlerComponent. These methods
have been moved to CakeRequest, and offer a new interface alongside a more backwards compatible
usage:
$this->request->is(’post’);
$this->request->isPost();
Both method calls will return the same value. For the time being the methods are still available on RequestHandler,
but are deprecated and still might be removed before the final release. You can also easily
extend the request detectors that are available, by using CakeRequest::addDetector() to create
new kinds of detectors. There are four different types of detectors that you can create:
• Environment value comparison - An environment value comparison, compares a value fetched from
env() to a known value the environment value is equality checked against the provided value.
• Pattern value comparison - Pattern value comparison allows you to compare a value fetched from
env() to a regular expression.
• Option based comparison - Option based comparisons use a list of options to create a regular expression.
Subsequent calls to add an already defined options detector will merge the options.
• Callback detectors - Callback detectors allow you to provide a ‘callback’ type to handle the check.
The callback will receive the request object as its only parameter.
Some examples would be:
// Add an environment detector.
$this->request->addDetector(’post’, array(’env’ => ’REQUEST_METHOD’, ’value’ => ’POST’));
// Add a pattern value detector.
$this->request->addDetector(’iphone’, array(’env’ => ’HTTP_USER_AGENT’, ’pattern’ => ’/iPhone/// Add an option detector
$this->request->addDetector(’internalIp’, array(
’env’ => ’CLIENT_IP’,
’options’ => array(’192.168.0.101’, ’192.168.0.100’)
));
// Add a callback detector. Can either be an anonymous function or a regular callable.
$this->request->addDetector(’awesome’, array(’callback’ => function ($request) {
return isset($request->awesome);
}));
CakeRequest also includes methods like CakeRequest::domain(),
CakeRequest::subdomains() and CakeRequest::host() to help applications with subdomains,
have a slightly easier life.
There are several built-in detectors that you can use:
• is(’get’) Check to see if the current request is a GET.
• is(’put’) Check to see if the current request is a PUT.

 
 
 

osdyui

Skills    Cakephp

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)