I had the issue that certain ctools-blocks won't show. After some digging i recognize that this is direct related to used custom formatter for those blocks.
Example formatter:
function mymodule_theme($existing, $type, $theme, $path) {
return array(
'title_header_formatter' => array(
'variables' => array('items' => NULL, 'attributes' => NULL)
),
);
}
After some more digging it shows that i got access denied for those blocks if the custom formatter is used.
In ctools/modules/ctools_block/src/Plugin/Block/EntityField.php:blockAccess() the block will be build and checked if the $build-array got children.
But if the build-array only have "#foobar"-keys the check on Element::children will return false.
if (Element::children($build)) {
return AccessResult::allowed();
}
I changed the check to !Element::isEmpty and those blocks with custom-formatter (and int his case only "#foobar"-keys) shows up in the frontend.
if (!Element::isEmpty($build)) {
return AccessResult::allowed();
}
If it's mandatory to have a least one children in an build-array - How to notice the developer of the custom formatter that this is mandatory?
If its not mandatory, the patch is added.
Greetings,
René
Comment | File | Size | Author |
---|---|---|---|
ctools_blocks--custom-formatter-block-avoid-access-deny.patch | 533 bytes | renefreund |
Comments
Comment #2
ckaotikThe formatter in this case provided a render array with a direct
#theme
call, without a wrapper element.Works:
Fails: