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
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

setConfig()

setConfig(\type  $config) 

Set new config settings via a new Config object.

Parameters

\type $config
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

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)

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getDataVersion()

getDataVersion() 

Get data file version

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getDataCreationTimestamp()

getDataCreationTimestamp() 

Get data file creation timestamp

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getDataRevision()

getDataRevision() 

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

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
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

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
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getLookupSource()

getLookupSource() : string

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

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

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
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean —

true=populated json batch cache files

clearCache()

clearCache() 

Remove all tree optimization cache files

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

sanitizeTree()

sanitizeTree() 

Throws

\Mobi_Mtld_DA_Exception_JsonException

seekProperties()

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

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
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

__loadTreeFromFile()

__loadTreeFromFile() 

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

loadCachedTreeRoot()

loadCachedTreeRoot() 

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

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

__populateCache()

__populateCache(  $force = true) 

for internal cache populations usages

Parameters

$force
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

cleanup()

cleanup() 

Remove the old batches and create the new root json.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getFileId()

getFileId(  $filePath) 

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

Parameters

$filePath
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

fixValues()

fixValues(  $node) 

Swap value ids with values in a tree node

Parameters

$node
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

cacheTree()

cacheTree(  $tree,   $depth) 

Break down tree and save to files.

Parameters

$tree
$depth
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

throwFileWrite()

throwFileWrite(  $path) 

Throw a file/directory write exception

Parameters

$path
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

rmdir()

rmdir(  $dir) 

Recursively remove files and dirs.

Parameters

$dir
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275