Constants

API_ID

API_ID = '1'

CACHED_JSON_INFO_FILE_NAME

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.

CACHED_JSON_HISTORY_FILE_NAME

CACHED_JSON_HISTORY_FILE_NAME = 'da-cache-history'

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

Properties

$stockUaHeaders

$stockUaHeaders : 

Type

$config

$config : 

Type

$tree

$tree : 

Type

$properties

$properties : 

Type

$lookupValue

$lookupValue : 

Type

$MIN_JSON_VERSION

$MIN_JSON_VERSION : 

Type

$XMSG_JSON_LOAD

$XMSG_JSON_LOAD : 

Type

$XMSG_JSON_VERSION

$XMSG_JSON_VERSION : 

Type

$XMSG_JSON_INVALID

$XMSG_JSON_INVALID : 

Type

$XMSG_JSON_MISSING_REGEX_RULES

$XMSG_JSON_MISSING_REGEX_RULES : 

Type

$XMSG_CLIENT_PROPERTIES_NOT_SUPPORTED

$XMSG_CLIENT_PROPERTIES_NOT_SUPPORTED : 

Type

$XMSG_FILE_NOT_FOUND

$XMSG_FILE_NOT_FOUND : 

Type

$treeRegexes

$treeRegexes : 

Type

$uaProps

$uaProps : 

Type

$clientProps

$clientProps : 

Type

$deviceIdPropNameId

$deviceIdPropNameId : 

Type

$jsonTempDir

$jsonTempDir : 

the directory in which the the api puts it's temp and cache files

Type

$jsonBatchDir

$jsonBatchDir : 

the directory in which the json fragments are put

Type

$lookupSource

$lookupSource : 

Type

$dataIsLoaded

$dataIsLoaded : 

Type

$MIN_BATCH_SIZE

$MIN_BATCH_SIZE : 

batch config

Type

$MAX_CACHE_JSON_FILES

$MAX_CACHE_JSON_FILES : 

max number of JSON files to keep in cache, older JSON files will be deleted.

Type

$treeValueDict

$treeValueDict : 

tree 'v' node

Type

$batchId

$batchId : 

recursive pointer

Type

$cacheRootJsonFilePath

$cacheRootJsonFilePath : 

path to the root json file 0.serialized

Type

$jsonDataFilePath

$jsonDataFilePath : 

path to the json file passed to the api

Type

Methods

__construct()

__construct(  $config) 

Create the JSON tree handler.

Parameters

$config

setConfig()

setConfig(\type  $config) 

Set new config settings via a new Config object.

Parameters

\type $config

loadTreeFromFile()

loadTreeFromFile(  $jsonDataFilePath) 

Load the JSON tree file into the handler.

Parameters

$jsonDataFilePath

Throws

\Mobi_Mtld_DA_Exception_DataFileException
\Mobi_Mtld_DA_Exception_JsonException

loadTreeFromString()

loadTreeFromString(  $json) 

Load the JSON tree into the handler.

Parameters

$json

Throws

\Mobi_Mtld_DA_Exception_JsonException

getPropertyNames()

getPropertyNames() 

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

getDataVersion()

getDataVersion() 

Get data file version

getDataCreationTimestamp()

getDataCreationTimestamp() 

Get data file creation timestamp

getDataRevision()

getDataRevision() 

putProperties()

putProperties(  $userAgent,   $stockUserAgents,   $clientside) 

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

Parameters

$userAgent
$stockUserAgents
$clientside

putTreeWalkProperties()

putTreeWalkProperties(  $userAgent,   $stockUserAgents = null) 

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

Parameters

$userAgent
$stockUserAgents

getLookupSource()

getLookupSource() : string

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

Returns

string —

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

populateCache()

populateCache(  $jsonDataFilePath,   $force = false) : boolean

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

Parameters

$jsonDataFilePath
$force

Returns

boolean —

true=populated json batch cache files

clearCache()

clearCache() 

Remove all tree optimization cache files

sanitizeTree()

sanitizeTree() 

Throws

\Mobi_Mtld_DA_Exception_JsonException

seekProperties()

seekProperties(  $node,   $string,   $props2Vals,   $matched,   $regexRules,   $exclusionKeysList) 

Seek properties for a user agent within a node. This is designed to be recursed, and only externally called with the node representing the top of the tree

Parameters

$node
$string
$props2Vals
$matched
$regexRules
$exclusionKeysList

filterPropertiesResult()

filterPropertiesResult(  $props2Vals,   $exclusionKeysList) 

Filter properties if present in exclusion key list ('s' node).

Parameters

$props2Vals
$exclusionKeysList

__loadTreeFromFile()

__loadTreeFromFile() 

loadCachedTreeRoot()

loadCachedTreeRoot() 

try to load the root cached json file, if not exists try to load and populate the original

__populateCache()

__populateCache(  $force = true) 

for internal cache populations usages

Parameters

$force

cleanup()

cleanup() 

Remove the old batches and create the new root json.

getFileId()

getFileId(  $filePath) 

Get a unique identifier a json-file e.g. (filetime, filesize), to know when the file is changed

Parameters

$filePath

fixValues()

fixValues(  $node) 

Swap value ids with values in a tree node

Parameters

$node

cacheTree()

cacheTree(  $tree,   $depth) 

Break down tree and save to files.

Parameters

$tree
$depth

throwFileWrite()

throwFileWrite(  $path) 

Throw a file/directory write exception

Parameters

$path

rmdir()

rmdir(  $dir) 

Recursively remove files and dirs.

Parameters

$dir