TOP

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.
Source
Config.php
Depends on
Mobi_Mtld_DA_CacheProvider_CacheProviderInterface
Package
Mobi\Mtld\DA\Device
Author
DeviceAtlas Limited

Constants

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.

Methods

getCacheProvider

Mobi_Mtld_DA_CacheProvider_CacheProviderInterface $obj->getCacheProvider()

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

getCookieName

string $obj->getCookieName()

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

getIgnoreDataFileChanges

boolean $obj->getIgnoreDataFileChanges()

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

Returns

boolean
true=include ua properties

getIncludeLangProps

bool $obj->getIncludeLangProps()

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

Returns

bool
true=include lang properties

getIncludeMatchInfo

bool $obj->getIncludeMatchInfo()

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

Returns

bool
true=include match info properties

getIncludeUaProps

boolean $obj->getIncludeUaProps()

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

Returns

boolean
true=include ua properties

getOptimizerTempDir

string $obj->getOptimizerTempDir()

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

Returns

string
path to the optimizer temp directory

getReturnNullWhenNoProperties

bool $obj->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.

Returns

bool
true=return null instead of empty array

getUseTreeOptimizer

bool $obj->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.
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

bool
true=data optimizer is on

setCacheProvider

void $obj->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.

Arguments

Returns

void

setCookieName

void $obj->setCookieName(string 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.

Arguments

    cookieName (string)
    The cookie name which the client side properties are set to. Set to null to turn off using client-side properties

Returns

void

setIgnoreDataFileChanges

void $obj->setIgnoreDataFileChanges(bool 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.

Arguments

    ignoreDataFileChanges (bool)
    true=include ua properties

Returns

void

setIncludeLangProps

void $obj->setIncludeLangProps(bool 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.

Arguments

    includeLangProps (bool)
    true=include lang properties

Returns

void

setIncludeMatchInfo

void $obj->setIncludeMatchInfo(bool includeMatchInfo)

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

Arguments

    includeMatchInfo (bool)
    true=include match info properties

Returns

void

setIncludeUaProps

void $obj->setIncludeUaProps(bool 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.

Arguments

    includeUaProps (bool)
    true=include ua properties

Returns

void

setOptimizerTempDir

void $obj->setOptimizerTempDir(string 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.

Arguments

    optimizerTempDir (string)
    path to temp directory

Returns

void

setReturnNullWhenNoProperties

void $obj->setReturnNullWhenNoProperties(bool 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.

Arguments

    returnNullWhenNoProperties (bool)
    true = return null instead of empty array

Returns

void

setUseTreeOptimizer

void $obj->setUseTreeOptimizer(bool 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.
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.

Arguments

    useTreeOptimizer (bool)
    true=turn on data optimizer (by default this config is off for DeviceApi but on for DeviceApiWeb)

Returns

void