ServerRequest - detectors

Could anyone give an example how to use/evaluate this code in bootstrap cakephp 4?

ServerRequest::addDetector(‘mobile’, function ($request) {
$detector = new \Detection\MobileDetect();

return $detector->isMobile();

});
ServerRequest::addDetector(‘tablet’, function ($request) {
$detector = new \Detection\MobileDetect();

return $detector->isTablet();

});

Kind regards Klaus

For example in a controller or a view:

if ($this->request->is('mobile')) {
    // do whatever ...
}

See also Cookbook > Request & Response Objects > Request > Checking Request Conditions