function entity_embed_get_dom_node_attributes_as_array in Entity Embed 7.2
Same name and namespace in other branches
- 7.3 includes/entity_embed.html.inc \entity_embed_get_dom_node_attributes_as_array()
- 7 includes/entity_embed.html.inc \entity_embed_get_dom_node_attributes_as_array()
Convert the attributes on a DOMNode object to an array.
This will also un-serialize any attribute values stored as JSON.
Parameters
\DOMNode $node: A DOMNode object.
Return value
array The attributes as an associative array, keyed by the attribute names.
1 call to entity_embed_get_dom_node_attributes_as_array()
- _entity_embed_render_placeholders in ./
entity_embed.module - Implements callback_filter_process().
File
- includes/
entity_embed.html.inc, line 208 - DOM processing functions.
Code
function entity_embed_get_dom_node_attributes_as_array(\DOMNode $node) {
$return = array();
// Convert the data attributes to the context array.
foreach ($node->attributes as $attribute) {
$key = $attribute->nodeName;
$return[$key] = $attribute->nodeValue;
// Check for JSON-encoded attributes.
$data = json_decode($return[$key], TRUE, 10);
if ($data !== NULL && json_last_error() === JSON_ERROR_NONE) {
$return[$key] = $data;
}
}
return $return;
}