Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DeviceDetector/MobileDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
* @author suncat2000 <[email protected]>
*
*/
class MobileDetector extends MobileDetect
class MobileDetector extends MobileDetect implements MobileDetectorInterface
{
}
76 changes: 76 additions & 0 deletions DeviceDetector/MobileDetectorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/*
* This file is part of the MobileDetectBundle.
*
* (c) Nikolay Ivlev <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SunCat\MobileDetectBundle\DeviceDetector;

/**
* MobileDetectorInterface interface
*
* @author pierrickmartos <[email protected]>
*
*/
interface MobileDetectorInterface
{
/**
* Check if the device is mobile.
* Returns true if any type of mobile device detected, including special ones
* @param null $userAgent deprecated
* @param null $httpHeaders deprecated
* @return bool
*/
public function isMobile($userAgent = null, $httpHeaders = null);

/**
* Check if the device is a tablet.
* Return true if any type of tablet device is detected.
*
* @param string $userAgent deprecated
* @param array $httpHeaders deprecated
* @return bool
*/
public function isTablet($userAgent = null, $httpHeaders = null);

/**
* This method checks for a certain property in the
* userAgent.
* @todo: The httpHeaders part is not yet used.
*
* @param string $key
* @param string $userAgent deprecated
* @param string $httpHeaders deprecated
* @return bool|int|null
*/
public function is($key, $userAgent = null, $httpHeaders = null);

/**
* Some detection rules are relative (not standard),
* because of the diversity of devices, vendors and
* their conventions in representing the User-Agent or
* the HTTP headers.
*
* This method will be used to check custom regexes against
* the User-Agent string.
*
* @param $regex
* @param string $userAgent
* @return bool
*
* @todo: search in the HTTP headers too.
*/
public function match($regex, $userAgent = null);

/**
* Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
*
* @return string One of the self::MOBILE_GRADE_* constants.
*/
public function mobileGrade();
}
3 changes: 2 additions & 1 deletion Resources/config/mobile_detect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

<services>

<service id="mobile_detect.mobile_detector.default" class="%mobile_detect.mobile_detector.class%"/>
<service id="mobile_detect.mobile_detector.default" class="%mobile_detect.mobile_detector.class%" autowire="true" autoconfigure="true" />
<service id="SunCat\MobileDetectBundle\DeviceDetector\MobileDetectorInterface" alias="mobile_detect.mobile_detector.default" />

<service id="mobile_detect.device_view" class="%mobile_detect.device_view.class%">
<argument type="service" id="request_stack" on-invalid="null"/>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"php": ">=5.5.9",
"symfony/framework-bundle": "~2.7|~3.3|~4.0|~5.0",
"mobiledetect/mobiledetectlib": "~2.8",
"twig/twig": "~1.26|~2.0||^3.0"
"twig/twig": "~1.26|~2.0|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35|^5.4.3|^6.0",
Expand Down