PKPTemplateManager::getResourcesByContext PHP Method

getResourcesByContext() public method

A helper function which retrieves script, style and header assets assigned to a particular context.
public getResourcesByContext ( $resources, $context ) : array
$resources array Requested resources
$context string Requested context
return array Resources assigned to these contexts
    function getResourcesByContext($resources, $context)
    {
        $matches = array();
        if (array_key_exists($context, $resources)) {
            $matches = $resources[$context];
        }
        $page = $this->get_template_vars('requestedPage');
        $page = empty($page) ? 'index' : $page;
        $op = $this->get_template_vars('requestedOp');
        $op = empty($op) ? 'index' : $op;
        $contexts = array(join('-', array($context, $page)), join('-', array($context, $page, $op)));
        foreach ($contexts as $context) {
            if (array_key_exists($context, $resources)) {
                foreach ($resources[$context] as $priority => $priorityList) {
                    if (!array_key_exists($priority, $matches)) {
                        $matches[$priority] = array();
                    }
                    $matches[$priority] = array_merge($matches[$priority], $resources[$context][$priority]);
                }
                $matches += $resources[$context];
            }
        }
        return $matches;
    }