diff --git a/App/Config/bootstrap.php b/App/Config/bootstrap.php index 171b481082..8ed30e9c65 100644 --- a/App/Config/bootstrap.php +++ b/App/Config/bootstrap.php @@ -59,6 +59,7 @@ use Cake\Error\ErrorHandler; use Cake\Log\Log; use Cake\Network\Email\Email; +use Cake\Network\Request; use Cake\Utility\Inflector; /** @@ -126,6 +127,17 @@ Email::config(Configure::consume('Email')); Log::config(Configure::consume('Log')); +/** + * Setup detectors for mobile and tablet. + */ +Request::addDetector('mobile', function($request) { + return (new \Detection\MobileDetect())->isMobile(); +}); + +Request::addDetector('tablet', function($request) { + return (new \Detection\MobileDetect())->isTablet(); +}); + /** * Custom Inflector rules, can be set to correctly pluralize or singularize table, model, controller names or whatever other * string is passed to the inflection functions diff --git a/composer.json b/composer.json index 2932b7f8e8..49d232256f 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,9 @@ "type": "project", "license": "MIT", "require": { + "php": ">=5.4", "cakephp/cakephp": "3.0.*-dev", - "php": ">=5.4" + "mobiledetect/mobiledetectlib": "2.*" }, "require-dev": { "d11wtq/boris": "1.0.*"