\Mobi_Mtld_DA_Device_Config

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.

Summary

Methods
Properties
Constants
setCookieName()
getCookieName()
setIncludeUaProps()
getIncludeUaProps()
setIncludeLangProps()
getIncludeLangProps()
setIncludeMatchInfo()
getIncludeMatchInfo()
setReturnNullWhenNoProperties()
getReturnNullWhenNoProperties()
setUseTreeOptimizer()
getUseTreeOptimizer()
setOptimizerTempDir()
getOptimizerTempDir()
setCacheProvider()
getCacheProvider()
setIgnoreDataFileChanges()
getIgnoreDataFileChanges()
No public properties found
DEFAULT_COOKIE_NAME
DEFAULT_INCLUDE_UA_PROPS
DEFAULT_INCLUDE_LANG_PROPS
DEFAULT_INCLUDE_MATCH_INFO
DEFAULT_RETURN_NULL_WHEN_NO_PROPERTIES
No protected methods found
No protected properties found
N/A
No private methods found
$cookieName
$includeUaProps
$includeLangProps
$includeMatchInfo
$returnNullWhenNoProperties
$useTreeOptimizer
$ignoreDataFileChanges
$cacheProvider
$optimizerTempDir
N/A

Constants

DEFAULT_INCLUDE_UA_PROPS

DEFAULT_INCLUDE_UA_PROPS = true

The default config value for getProperties() to include User-Agent dynamic properties.

DEFAULT_INCLUDE_LANG_PROPS

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

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_RETURN_NULL_WHEN_NO_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.

Properties

$cookieName

$cookieName : 

Type

$includeUaProps

$includeUaProps : 

Type

$includeLangProps

$includeLangProps : 

Type

$includeMatchInfo

$includeMatchInfo : 

Type

$returnNullWhenNoProperties

$returnNullWhenNoProperties : 

Type

$useTreeOptimizer

$useTreeOptimizer : 

Type

$ignoreDataFileChanges

$ignoreDataFileChanges : 

Type

$cacheProvider

$cacheProvider : 

Type

$optimizerTempDir

$optimizerTempDir : 

Type

Methods

setCookieName()

setCookieName(  $cookieName) 

To change the cookie name that the client side properties would be set to.

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

getCookieName()

getCookieName() : string

Get the cookie name that the client side properties would be set to.

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).

Returns

string —

The cookie name which the client side properties are set to

setIncludeUaProps()

setIncludeUaProps(  $includeUaProps) 

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.

If you do not use this properties you can set this config to false to make the detection marginally faster.

Parameters

$includeUaProps

getIncludeUaProps()

getIncludeUaProps() : boolean

Get if the User-Agent properties are being included in the property set or not.

Returns

boolean —

true=include ua properties

setIncludeLangProps()

setIncludeLangProps(  $includeLangProps) 

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.

If you do not use this properties you can set this config to false to make the detection marginally faster.

Parameters

$includeLangProps

getIncludeLangProps()

getIncludeLangProps() : boolean

Get if the language/locale properties are being included in the property set or not.

Returns

boolean —

true=include lang properties

setIncludeMatchInfo()

setIncludeMatchInfo(  $includeMatchInfo) 

To disable or enable getProperties() including the matched and unmatched parts of the User-Agent to the property set.

Parameters

$includeMatchInfo

getIncludeMatchInfo()

getIncludeMatchInfo() : boolean

To get if getProperties() include the matched and unmatched parts of the User-Agent to the property set.

Returns

boolean —

true=include match info properties

setReturnNullWhenNoProperties()

setReturnNullWhenNoProperties(  $returnNullWhenNoProperties) 

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.

Parameters

$returnNullWhenNoProperties

getReturnNullWhenNoProperties()

getReturnNullWhenNoProperties() : boolean

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.

Returns

boolean —

true=return null instead of empty array

setUseTreeOptimizer()

setUseTreeOptimizer(  $useTreeOptimizer) 

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.

Parameters

$useTreeOptimizer

getUseTreeOptimizer()

getUseTreeOptimizer() : boolean

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.

Returns

boolean —

true=data optimizer is on

setOptimizerTempDir()

setOptimizerTempDir(  $optimizerTempDir) 

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.

Parameters

$optimizerTempDir

getOptimizerTempDir()

getOptimizerTempDir() : string

Get the temp directory path in which the optimizer puts the cached files.

Returns

string —

path to the optimizer temp directory

setCacheProvider()

setCacheProvider(\Mobi_Mtld_DA_CacheProvider_CacheProviderInterface  $cacheProvider) 

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.

Parameters

\Mobi_Mtld_DA_CacheProvider_CacheProviderInterface $cacheProvider

getCacheProvider()

getCacheProvider() : \Mobi_Mtld_DA_CacheProvider_CacheProviderInterface

Get the cache provider instance being used by the API to cache the lookup results.

null is returned when a cache provider is not used.

Returns

\Mobi_Mtld_DA_CacheProvider_CacheProviderInterface

cacheProvider a cache provider instance or null

setIgnoreDataFileChanges()

setIgnoreDataFileChanges(  $ignoreDataFileChanges) 

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.

Parameters

$ignoreDataFileChanges

getIgnoreDataFileChanges()

getIgnoreDataFileChanges() : boolean

Get if the data file optimizer should do data file update automatic checking.

Returns

boolean —

true=include ua properties