function _acquia_purge_action_purge in Acquia Purge 6
Same name and namespace in other branches
- 7 acquia_purge.rules.inc \_acquia_purge_action_purge()
Action callback to the "Purge a path from Varnish on Acquia Cloud" rule.
File
- ./
acquia_purge.rules.inc, line 33 - Rules integration that provides a purge action as rule action.
Code
function _acquia_purge_action_purge($configured_paths) {
$paths = array();
// As users can enter these paths, we are treating them as tainted input.
foreach (explode("\n", $configured_paths) as $configured_path) {
// We begin by copying a trimmed version of the given line.
$path = trim($configured_path);
// And we strip off starting or trailing slashes, not belonging to a path.
$path = trim($path, '/');
// And strip double slashes that slipped in accidentally.
$path = str_replace('//', '/', $path);
// Add if the string isn't empty and only when it is new in the list.
if (!empty($path) && !in_array($path, $paths)) {
$paths[] = $path;
}
}
// Relay the purging of these paths to our API helper and we are done here.
acquia_purge_purge_paths($paths);
}