public function AuthcacheP13nObjectResourcePreprocessor::preprocess in Authenticated User Page Caching (Authcache) 7.2
Process a list of resource definitions.
File
- modules/
authcache_p13n/ includes/ AuthcacheP13nObjectResourcePreprocessor.inc, line 35 - Defines the class AuthcacheP13nObjectResourcePreprocessor.
Class
- AuthcacheP13nObjectResourcePreprocessor
- A utility class suitable for preparing resources for the object factory.
Code
public function preprocess(array $resources) {
// Priority queue for processable resources.
$priq = array(
array(
0,
$resources,
),
);
$enqueue = function (array $new_resources, $priority = 0) use (&$priq) {
$priq[] = array(
$priority,
$new_resources,
);
};
// Process all unprocessed resources and put them into the result map.
$processed = array();
while (count($priq)) {
list($priority, $definitions) = array_shift($priq);
foreach ($definitions as $key => $definition) {
foreach ($this->preprocessors as $processor) {
$result = call_user_func($processor, $definition, $priority, $key, $enqueue);
if (isset($result)) {
$definition = $result;
}
}
$processed[$priority][$key] = $definition;
}
}
// Sort processed resource sets by priority.
ksort($processed);
// Merge processed resource sets into one.
$result = array();
foreach ($processed as $definitions) {
foreach ($definitions as $key => $definition) {
$result[$key] = $definition;
}
}
return $this
->sanitize($result);
}