public static function TagView::formatTargeting in Doubleclick for Publishers (DFP) 8
Formats a targeting array.
Parameters
array $targeting: The targeting array. An array of arrays. Each each has two keys 'target' and 'value'. The 'target' value is a string. The 'value' value is a string with multiple values delimited by a comma.
\Drupal\dfp\TokenInterface $token: The DFP token service.
\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler.
\Drupal\dfp\View\TagView|NULL $tag_view: (optional) The TagView object. Defaults to NULL.
Return value
array An array of arrays. Each each has two keys 'target' and 'value'. The 'target' value is a trimmed string. The 'value' value is an array of strings, also trimmed.
2 calls to TagView::formatTargeting()
- DfpHtmlResponseAttachmentsProcessor::getHeadBottom in src/
DfpHtmlResponseAttachmentsProcessor.php - Gets the javascript to add after the slot definitions.
- TagView::getTargeting in src/
View/ TagView.php - Gets the ad targeting.
File
- src/
View/ TagView.php, line 264 - Contains \Drupal\dfp\View\TagView.
Class
- TagView
- A value object to combine a DFP tag with global settings for display.
Namespace
Drupal\dfp\ViewCode
public static function formatTargeting(array $targeting, TokenInterface $token, ModuleHandlerInterface $module_handler, TagView $tag_view = NULL) {
foreach ($targeting as $key => &$target) {
$target['target'] = trim($target['target']);
$target['value'] = $token
->replace($target['value'], $tag_view, [
'clear' => TRUE,
]);
// The target value could be blank if tokens are used. If so, remove it.
if (empty($target['value'])) {
unset($targeting[$key]);
continue;
}
// Allow other modules to alter the target.
$module_handler
->alter('dfp_target', $target);
// Convert the values into an array.
$target['value'] = array_map('trim', explode(',', $target['value']));
}
return $targeting;
}