MobileDetectBundle icon indicating copy to clipboard operation
MobileDetectBundle copied to clipboard

Make mobile_detect.mobile_detector use the device_view cookie feature

Open adrienbrault opened this issue 9 years ago • 2 comments

Hey,

I was puzzled when first messing around with the toolbar feature to change the current view type, because it would not change the result of $container->get('mobile_detect.mobile_detector')->isMobile()

adrienbrault avatar Sep 02 '16 15:09 adrienbrault

you should use the mobile_detect.device_view helper with method isMobileView

erikbaan avatar Jan 30 '17 08:01 erikbaan

The mobile_detect.device_view service is a private service, which causes a deprecation notice because getting private services wil fail in symfony 4. I prefer adding the isMobileView() etc. methods to the mobile_detect.mobile_detector service. It's way more in line with the available Twig Functions.

In Twig it's very easy to do so, just calling is_mobile_view() function, but in PHP you have to get another service to do so, which in turn is private.

leroy0211 avatar Mar 28 '19 09:03 leroy0211