Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
zendframework1
library
Zend
Http
UserAgent
Features
Adapter
TeraWurfl.php
Go to the documentation of this file.
1
<?php
25
#require_once 'Zend/Http/UserAgent/Features/Adapter.php';
26
37
class
Zend_Http_UserAgent_Features_Adapter_TeraWurfl
implements
Zend_Http_UserAgent_Features_Adapter
38
{
45
public
static
function
getFromRequest
(
$request
, array
$config
)
46
{
47
if
(!
class_exists
(
'TeraWurfl'
)) {
48
// If TeraWurfl class not found, see if we can load it from
49
// configuration
50
//
51
if
(!isset(
$config
[
'terawurfl'
])) {
52
// No configuration
53
#require_once 'Zend/Http/UserAgent/Features/Exception.php';
54
throw
new
Zend_Http_UserAgent_Features_Exception
(
'"TeraWurfl" configuration is not defined'
);
55
}
56
57
$config
=
$config
[
'terawurfl'
];
58
59
if
(empty(
$config
[
'terawurfl_lib_dir'
])) {
60
// No lib_dir given
61
#require_once 'Zend/Http/UserAgent/Features/Exception.php';
62
throw
new
Zend_Http_UserAgent_Features_Exception
(
'The "terawurfl_lib_dir" parameter is not defined'
);
63
}
64
65
// Include the Tera-WURFL file
66
#require_once ($config['terawurfl_lib_dir'] . '/TeraWurfl.php');
67
}
68
69
70
// instantiate the Tera-WURFL object
71
$wurflObj =
new
TeraWurfl();
72
73
// Get the capabilities of the current client.
74
$matched = $wurflObj->getDeviceCapabilitiesFromRequest(array_change_key_case(
$request
, CASE_UPPER));
75
76
return
self::getAllCapabilities
($wurflObj);
77
}
78
79
/***
80
* Builds an array with all capabilities
81
*
82
* @param TeraWurfl $wurflObj TeraWurfl object
83
*/
84
public
static
function
getAllCapabilities
(TeraWurfl $wurflObj)
85
{
86
87
foreach
($wurflObj->capabilities as
$group
) {
88
if
(!is_array(
$group
)) {
89
continue
;
90
}
91
foreach
(
$group
as $key =>
$value
) {
92
if
(is_bool(
$value
)) {
93
// to have the same type than the official WURFL API
94
$features[$key] = (
$value
?
'true'
:
'false'
);
95
}
else
{
96
$features[$key] =
$value
;
97
}
98
}
99
}
100
return
$features;
101
}
102
}
Zend_Http_UserAgent_Features_Adapter_TeraWurfl\getFromRequest
static getFromRequest($request, array $config)
Definition:
TeraWurfl.php:45
$config
$config
Definition:
fraud_order.php:17
$group
$group
Definition:
sections.phtml:16
$value
$value
Definition:
gender.phtml:16
Zend_Http_UserAgent_Features_Exception
Definition:
Exception.php:34
$request
$request
Definition:
quote_with_configurable_product_last_variation.php:22
Magento\Framework\Code\Generator\class_exists
class_exists($className)
Definition:
DefinedClassesTest.php:15
Zend_Http_UserAgent_Features_Adapter_TeraWurfl\getAllCapabilities
static getAllCapabilities(TeraWurfl $wurflObj)
Definition:
TeraWurfl.php:84
Zend_Http_UserAgent_Features_Adapter
Definition:
Adapter.php:31
Zend_Http_UserAgent_Features_Adapter_TeraWurfl
Definition:
TeraWurfl.php:37