function authcache_p13n_client_get_preferred in Authenticated User Page Caching (Authcache) 7.2
Return the preferred client for the given fragment/assembly/setting.
Related topics
6 calls to authcache_p13n_client_get_preferred()
- AuthcacheP13nTestClient::testGetPreferredClientCustomList in modules/
authcache_p13n/ tests/ authcache_p13n.client.test - Cover authcache_p13n_client_get_preferred() with custom list.
- AuthcacheP13nTestClient::testGetPreferredClientDefaultClientList in modules/
authcache_p13n/ tests/ authcache_p13n.client.test - Cover authcache_p13n_client_get_preferred().
- template_preprocess_authcache_p13n_assembly in modules/
authcache_p13n/ authcache_p13n.module - Preprocess a placeholder for a personalized assembly.
- template_preprocess_authcache_p13n_fragment in modules/
authcache_p13n/ authcache_p13n.module - Preprocess a placeholder for a personalized fragment.
- template_preprocess_authcache_p13n_partial in modules/
authcache_p13n/ authcache_p13n.module - Preprocess a placeholder for a part of an assembly.
File
- modules/
authcache_p13n/ authcache_p13n.module, line 692 - Provides methods for serving personalized content fragments.
Code
function authcache_p13n_client_get_preferred($type, $id, $clients = NULL) {
$preferred_clients =& drupal_static(__FUNCTION__);
if (!isset($preferred_clients[$type][$id])) {
// Gather clients available during the current page request.
$available_clients = array_filter(authcache_p13n_client_info(), function ($client) {
return !empty($client['enabled']);
});
// Check for clients enabled in the given configuration.
if (!isset($clients)) {
$clients = $available_clients;
}
drupal_alter('authcache_p13n_client_order', $clients, $type, $id);
$enabled_clients = array_filter($clients, function ($client) {
return !isset($client['status']) || !empty($client['status']);
});
// Collect and sort configured clients.
$configured_clients = array_intersect_key($enabled_clients, $available_clients);
foreach (array_keys($configured_clients) as $name) {
$configured_clients[$name] += $available_clients[$name];
}
uasort($configured_clients, 'drupal_sort_weight');
$preferred_clients[$type][$id] = key($configured_clients) ?: FALSE;
}
// Return the first configured client.
return $preferred_clients[$type][$id];
}