TOP

Mobi_Mtld_DA_Device_TreeOptimized

This class is used by the main API class and should not be used directly.
Package
Mobi\Mtld\DA\Device
Author
DeviceAtlas Limited

Constants

CACHED_JSON_HISTORY_FILE_NAME = 'da-cache-history'

Name of the file that keeps a history of the cached data file directories.

CACHED_JSON_INFO_FILE_NAME = 'da-cached-info'

Name of the file that stores the cached data file's file-size and file-modification-time. This info is used to sense auto data file changes.

Methods

__construct

Mobi_Mtld_DA_Device_TreeOptimized $obj = new Mobi_Mtld_DA_Device_TreeOptimized()

Create the JSON tree handler.

Returns

void

getDataCreationTimestamp

void $obj->getDataCreationTimestamp()

Get data file creation timestamp

Returns

void

getDataVersion

void $obj->getDataVersion()

Get data file version

Returns

void

getLookupSource

string $obj->getLookupSource()

Get the source properties fetch source to be used for debugging.

Returns

string
'tree' or 'optimized tree' or 'cache'

getPropertyNames

void $obj->getPropertyNames()

Get the list of all available property names from the tree (not contains client side props)

Returns

void

loadTreeFromFile

void $obj->loadTreeFromFile()

Load the JSON tree file into the handler.

Returns

void

Throws

loadTreeFromString

void $obj->loadTreeFromString()

Load the JSON tree into the handler.

Returns

void

Throws

putProperties

void $obj->putProperties(string userAgent, array stockUserAgents, string clientside)

Get properties from tree walk/ua/client-side and put them in the tree.properties use cached properties if exists.

Arguments

    userAgent (string)
    user-agent string (from the original User-Agent header) to be used for detecting ua-props
    stockUserAgents (array)
    list of candidate user-agent strings to be used for the tree walk
    clientside (string)
    client side properties or null

Returns

void

putTreeWalkProperties

void $obj->putTreeWalkProperties(userAgent user-agent, stockUserAgents list)

Get properties from tree walk/ua and put them in the tree.properties if stockUserAgents != null - iterate over stockUserAgents for each item: tree-walk and stop iteration if result has deviceId - use userAgent for detecting the ua-props if stockUserAgents == null - use userAgent for tree walk - use userAgent for detecting the ua-props

Arguments

    user-agent (userAgent)
    string (from the original User-Agent header)
    list (stockUserAgents)
    of candidate user-agent strings to be used for tree walk

Returns

void

setConfig

void $obj->setConfig(type $config)

Set new config settings via a new Config object.

Arguments

    $config (type)

Returns

void

clearCache

void $obj->clearCache()

Remove all tree optimization cache files

Returns

void

populateCache

bool $obj->populateCache(bool force=false)

Break down the DeviceAtlas JSON data file into smaller files and save the batch into "/da-api-temp-dir/batch-cache-dir".

Arguments

    force=false (bool)
    false=do not populate if batch already exists

Returns

bool
true=populated json batch cache files