Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Maybe I'm misinterpreting things, but there is a portion of the API.txt file that is confusing.
The section labeled "Altering the Replacement Values", last line of the last paragraph, says
"The return value will be an array with tokens as keys to their own replacement values."
When I first read this, I expected something like...
array(
token1 => value1,
token2 => value2,
etc.
);
Instead, the array (or more accurately, object) looks like...
stdClass Object {
[tokens] => array(
[0] => mytoken1,
[1] => mytoken2
),
[values] => array(
[0] => value1,
[1] => value2,
)
}
Perhaps the simplest way to handle this would be to add an example to the documentation.
Comments
Comment #1
gregglesQuite confusing indeed! Thanks for noticing, submitting an issue, and providing an idea for how to fix it.
I do wonder if we should be returning an object or an array of arrays, though that's a question for a different issue.
Fixed - new text below.
"The return value will be an object containing one array of tokens
and one array of values as in this example:
stdClass Object {
[tokens] => array(
[0] => mytoken1,
[1] => mytoken2
),
[values] => array(
[0] => value1,
[1] => value2,
)
}"
Comment #2
(not verified) CreditAttribution: commented