Skip to content

Instantly share code, notes, and snippets.

@init90
Created November 12, 2018 11:09
Show Gist options
  • Save init90/f8ea2b81083fc7a228e52a8e48f75b18 to your computer and use it in GitHub Desktop.
Save init90/f8ea2b81083fc7a228e52a8e48f75b18 to your computer and use it in GitHub Desktop.
/**
* Set product output across panel.
*
* @param string $bundle_name
* Product bundle name.
*/
function sgpt_add_new_type_to_panel_settings($bundle_name) {
$task_name = 'node_view';
$variant_name = 'node_view__product';
$node_view_tasks = page_manager_get_task($task_name);
$task_handlers = page_manager_load_task_handlers($node_view_tasks);
if (!empty($task_handlers[$variant_name])) {
$variant = $task_handlers[$variant_name];
if (empty($variant->conf['access']['plugins'][0]['settings']['type'])) {
return FALSE;
}
$variant_settings = &$variant->conf['access']['plugins'][0]['settings']['type'];
$variant_settings[$bundle_name] = $bundle_name;
page_manager_save_task_handler($variant);
page_manager_task_handler_ctools_access_set(
"{$task_name}*{$variant_name}",
$variant->conf['access']
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment