In ctools.api.php the function hook_ctools_content_subtype_alter should take the variables $subtype and $plugin by reference. I guess this is just a miss in the documentation.

function hook_ctools_content_subtype_alter($subtype, $plugin) {
}

Should be

function hook_ctools_content_subtype_alter(&$subtype, &$plugin) {
}

So that the category name for example can be changed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pontus_nilsson’s picture

Attached patch passes the variables by reference.

David_Rothstein’s picture

Status: Active » Needs review

$subtype definitely should be, but why $plugin? The code which invokes this hook, ctools_content_prepare_subtype(), only takes $subtype by reference itself, so if you modify $plugin in this hook I don't think it would actually have any effect? (and I assume that's intentional)

Note that I included the change to take $subtype by reference as part of #2373297: hook_ctools_content_subtype_alter() does not provide any reliable way to identify the subtype being altered since I noticed that issue too and was already changing that exact line of code in the documentation.

rivimey’s picture

Status: Needs review » Closed (outdated)