Mobi_Mtld_DA_Device_Config
in package
DeviceApi Configurations. To change the default configs of the DeviceAtlas DeviceApi create an instance of this class, set your preferred configs and pass the instance to the constructor of a DeviceApi or DeviceApiWeb. Note that you may change the configs even after the Config instance has been passed to the DeviceApi.
Tags
Table of Contents
- DEFAULT_COOKIE_NAME = "DAPROPS"
- The default cookie name that the client side properties would be set to.
- DEFAULT_INCLUDE_LANG_PROPS = \true
- The default config value for getProperties(HEADERS) or getProperties(REQUEST) to check the Accept-Language header and include properties to the property set for getting client's language and locale preferences.
- DEFAULT_INCLUDE_MATCH_INFO = \false
- The default config value for getProperties() to include the matched and unmatched parts of the User-Agent to the property set.
- DEFAULT_INCLUDE_UA_PROPS = \true
- The default config value for getProperties() to include User-Agent dynamic properties.
- DEFAULT_RETURN_NULL_WHEN_NO_PROPERTIES = \false
- The default config value for getProperties() return value when there was no properties. true = if no properties return null, false = if no property return an instance of Properties with no Property inside it.
- $cacheProvider : mixed
- $cookieName : mixed
- $ignoreDataFileChanges : mixed
- $includeLangProps : mixed
- $includeMatchInfo : mixed
- $includeUaProps : mixed
- $optimizerTempDir : mixed
- $returnNullWhenNoProperties : mixed
- $useTreeOptimizer : mixed
- getCacheProvider() : Mobi_Mtld_DA_CacheProvider_CacheProviderInterface
- Get the cache provider instance being used by the API to cache the lookup results.
- getCookieName() : string
- Get the cookie name that the client side properties would be set to.
- getIgnoreDataFileChanges() : bool
- Get if the data file optimizer should do data file update automatic checking.
- getIncludeLangProps() : bool
- Get if the language/locale properties are being included in the property set or not.
- getIncludeMatchInfo() : bool
- To get if getProperties() include the matched and unmatched parts of the User-Agent to the property set.
- getIncludeUaProps() : bool
- Get if the User-Agent properties are being included in the property set or not.
- getOptimizerTempDir() : string
- Get the temp directory path in which the optimizer puts the cached files.
- getReturnNullWhenNoProperties() : bool
- Get if the value returned by getProperties() should be null when there are no properties to return or an instance of Properties that has no Property inside it should be returned.
- getUseTreeOptimizer() : bool
- To get data optimization status. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.
- setCacheProvider() : mixed
- Set a cache provider to the API to cache the lookup results. This will dramatically increase the lookup performance in most situations. It is highly recommend to use this config when detecting devices in real-time using DeviceAtlasWeb.
- setCookieName() : mixed
- To change the cookie name that the client side properties would be set to.
- setIgnoreDataFileChanges() : mixed
- When data file optimizer is set to true using the "setUseTreeOptimizer()" config, the API will try to use a batch of optimized cached files instead of the original data file, the API will do several checks to pick between the cached data file or the passed data file. While this makes the API automatically sense and update the cached files. However if you manually update the optimizer caches using the provided CLI tool (ExtraTools/DeviceApi/data-file-optimizer.php) the checking is redundant and unnecessary, using this setting you can turn this checking off.
- setIncludeLangProps() : mixed
- To disable or enable getProperties(HEADERS) or getProperties(REQUEST) including language and locale properties. To check the Accept-Language header and include properties to the property set for getting client's language and locale preferences set to true.
- setIncludeMatchInfo() : mixed
- To disable or enable getProperties() including the matched and unmatched parts of the User-Agent to the property set.
- setIncludeUaProps() : mixed
- To disable or enable getProperties(HEADERS) or getProperties(REQUEST) including language and locale properties. To check the Accept-Language header and include properties to the property set for getting client's language and locale preferences set to true.
- setOptimizerTempDir() : mixed
- When optimizer is turned on, the cached files will be put inside the system directory by default, you can change the default optimizer temp/cache directory with this method.
- setReturnNullWhenNoProperties() : mixed
- Set if the value returned by the getProperties() method should be null when there are no properties to return or whether an empty Properties object should be returned instead.
- setUseTreeOptimizer() : mixed
- To optimize data. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.
Constants
DEFAULT_COOKIE_NAME
The default cookie name that the client side properties would be set to.
public
mixed
DEFAULT_COOKIE_NAME
= "DAPROPS"
When using getProperties() in a web application, the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas client side component (JS lib) to your web-site pages.
DEFAULT_INCLUDE_LANG_PROPS
The default config value for getProperties(HEADERS) or getProperties(REQUEST) to check the Accept-Language header and include properties to the property set for getting client's language and locale preferences.
public
mixed
DEFAULT_INCLUDE_LANG_PROPS
= \true
DEFAULT_INCLUDE_MATCH_INFO
The default config value for getProperties() to include the matched and unmatched parts of the User-Agent to the property set.
public
mixed
DEFAULT_INCLUDE_MATCH_INFO
= \false
DEFAULT_INCLUDE_UA_PROPS
The default config value for getProperties() to include User-Agent dynamic properties.
public
mixed
DEFAULT_INCLUDE_UA_PROPS
= \true
DEFAULT_RETURN_NULL_WHEN_NO_PROPERTIES
The default config value for getProperties() return value when there was no properties. true = if no properties return null, false = if no property return an instance of Properties with no Property inside it.
public
mixed
DEFAULT_RETURN_NULL_WHEN_NO_PROPERTIES
= \false
Properties
$cacheProvider
private
mixed
$cacheProvider
$cookieName
private
mixed
$cookieName
= self::DEFAULT_COOKIE_NAME
$ignoreDataFileChanges
private
mixed
$ignoreDataFileChanges
= \false
$includeLangProps
private
mixed
$includeLangProps
= self::DEFAULT_INCLUDE_LANG_PROPS
$includeMatchInfo
private
mixed
$includeMatchInfo
= self::DEFAULT_INCLUDE_MATCH_INFO
$includeUaProps
private
mixed
$includeUaProps
= self::DEFAULT_INCLUDE_UA_PROPS
$optimizerTempDir
private
mixed
$optimizerTempDir
$returnNullWhenNoProperties
private
mixed
$returnNullWhenNoProperties
= self::DEFAULT_RETURN_NULL_WHEN_NO_PROPERTIES
$useTreeOptimizer
private
mixed
$useTreeOptimizer
= \false
Methods
getCacheProvider()
Get the cache provider instance being used by the API to cache the lookup results.
public
getCacheProvider() : Mobi_Mtld_DA_CacheProvider_CacheProviderInterface
null is returned when a cache provider is not used.
Return values
Mobi_Mtld_DA_CacheProvider_CacheProviderInterface —cacheProvider a cache provider instance or null
getCookieName()
Get the cookie name that the client side properties would be set to.
public
getCookieName() : string
When using getProperties() in a web application, the detection would
automatically use the contents of this cookie if it exists. If you want
the client side properties to be used add the DeviceAtlas client side
component (JS lib) to your web-site pages.
When the user-agent or HTTP headers are set manually to getProperties()
the client side properties (probably the value set to the cookie)
can be manually passed to this methods as the second argument, note that
this config is only used for getProperties(REQUEST-OBJECT).
Return values
string —The cookie name which the client side properties are set to
getIgnoreDataFileChanges()
Get if the data file optimizer should do data file update automatic checking.
public
getIgnoreDataFileChanges() : bool
Return values
bool —true=include ua properties
getIncludeLangProps()
Get if the language/locale properties are being included in the property set or not.
public
getIncludeLangProps() : bool
Return values
bool —true=include lang properties
getIncludeMatchInfo()
To get if getProperties() include the matched and unmatched parts of the User-Agent to the property set.
public
getIncludeMatchInfo() : bool
Return values
bool —true=include match info properties
getIncludeUaProps()
Get if the User-Agent properties are being included in the property set or not.
public
getIncludeUaProps() : bool
Return values
bool —true=include ua properties
getOptimizerTempDir()
Get the temp directory path in which the optimizer puts the cached files.
public
getOptimizerTempDir() : string
Return values
string —path to the optimizer temp directory
getReturnNullWhenNoProperties()
Get if the value returned by getProperties() should be null when there are no properties to return or an instance of Properties that has no Property inside it should be returned.
public
getReturnNullWhenNoProperties() : bool
Return values
bool —true=return null instead of empty array
getUseTreeOptimizer()
To get data optimization status. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.
public
getUseTreeOptimizer() : bool
Return values
bool —true=data optimizer is on
setCacheProvider()
Set a cache provider to the API to cache the lookup results. This will dramatically increase the lookup performance in most situations. It is highly recommend to use this config when detecting devices in real-time using DeviceAtlasWeb.
public
setCacheProvider(Mobi_Mtld_DA_CacheProvider_CacheProviderInterface $cacheProvider) : mixed
Parameters
- $cacheProvider : Mobi_Mtld_DA_CacheProvider_CacheProviderInterface
Return values
mixed —setCookieName()
To change the cookie name that the client side properties would be set to.
public
setCookieName(mixed $cookieName) : mixed
When using getProperties() in a web application, the detection would
automatically use the contents of this cookie if it exists. If you want
the client side properties to be used add the DeviceAtlas client side
component (JS lib) to your web-site pages.
When the user-agent or HTTP headers are set manually to getProperties()
the client side properties (probably the value set to the cookie) can be
manually passed to this methods as the second argument, note that this
config is only used for getProperties(REQUEST-OBJECT). If you set the
cookie-name to null then the client-side properties cookie will be ignored.
Parameters
- $cookieName : mixed
Return values
mixed —setIgnoreDataFileChanges()
When data file optimizer is set to true using the "setUseTreeOptimizer()" config, the API will try to use a batch of optimized cached files instead of the original data file, the API will do several checks to pick between the cached data file or the passed data file. While this makes the API automatically sense and update the cached files. However if you manually update the optimizer caches using the provided CLI tool (ExtraTools/DeviceApi/data-file-optimizer.php) the checking is redundant and unnecessary, using this setting you can turn this checking off.
public
setIgnoreDataFileChanges(mixed $ignoreDataFileChanges) : mixed
Parameters
- $ignoreDataFileChanges : mixed
Return values
mixed —setIncludeLangProps()
To disable or enable getProperties(HEADERS) or getProperties(REQUEST) including language and locale properties. To check the Accept-Language header and include properties to the property set for getting client's language and locale preferences set to true.
public
setIncludeLangProps(mixed $includeLangProps) : mixed
If you do not use this properties you can set this config to false to make the detection marginally faster.
Parameters
- $includeLangProps : mixed
Return values
mixed —setIncludeMatchInfo()
To disable or enable getProperties() including the matched and unmatched parts of the User-Agent to the property set.
public
setIncludeMatchInfo(mixed $includeMatchInfo) : mixed
Parameters
- $includeMatchInfo : mixed
Return values
mixed —setIncludeUaProps()
To disable or enable getProperties(HEADERS) or getProperties(REQUEST) including language and locale properties. To check the Accept-Language header and include properties to the property set for getting client's language and locale preferences set to true.
public
setIncludeUaProps(mixed $includeUaProps) : mixed
If you do not use this properties you can set this config to false to make the detection marginally faster.
Parameters
- $includeUaProps : mixed
Return values
mixed —setOptimizerTempDir()
When optimizer is turned on, the cached files will be put inside the system directory by default, you can change the default optimizer temp/cache directory with this method.
public
setOptimizerTempDir(mixed $optimizerTempDir) : mixed
Parameters
- $optimizerTempDir : mixed
Return values
mixed —setReturnNullWhenNoProperties()
Set if the value returned by the getProperties() method should be null when there are no properties to return or whether an empty Properties object should be returned instead.
public
setReturnNullWhenNoProperties(mixed $returnNullWhenNoProperties) : mixed
Parameters
- $returnNullWhenNoProperties : mixed
Return values
mixed —setUseTreeOptimizer()
To optimize data. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.
public
setUseTreeOptimizer(mixed $useTreeOptimizer) : mixed
Parameters
- $useTreeOptimizer : mixed