Hi,
When visiting my admin/content/<entity>/%
path, I get a E_WARNING level error, along with a WSOD because the function entity_ui_entity_page_view()
cannot be found.
I am using the new EntityBundleableUIController controller class in my hook_entity_info
implementation. Here is my 'admin ui'
snippet:
'admin ui' => array(
'path' => 'admin/content/benchmark',
'file' => 'benchmark.admin.inc',
// Use a general wildcard loader, instead of a per-bundle one.
'menu wildcard' => '%benchmark',
// EntityDefaultUIController
'controller class' => 'EntityBundleableUIController',
),
and here is the error message:
call_user_func_array() expects parameter 1 to be a valid callback, function 'entity_ui_entity_page_view' not found or invalid function name
What does this mean? Does it mean that when using EntityBundleableUIController (which is very nice btw, thanks!) we have to extend the UI Controller class in order to implement our own entity_ui_entity_page_view()
? If I commented out the file
parameter, then Entity API is not able to find the entity forms (i.e., benchmark_form
). I don't know if this is a bug or if I'm missing some parameter that goes along the new UI Controller on the hook entity info.
Thank you.
Comments
Comment #1
Alexander Allen CreditAttribution: Alexander Allen commentedUnlike most of the menu callbacks defined in the UI controllers'
hook_menu
,$this->path . '/' . $wildcard
onEntityContentUIController::hook_menu()
does not try to figure out the 'page callback' dynamically - i.e., likeentity_ui_get_form()
does.Adding 'file' and 'file path' to the menu item fixed the WSOD:
After clearing the caches and verifying the menu_router table,
entity_ui_entity_page_view()
is the only callback pointing tosites/all/modules/contrib/entity/includes/entity.ui.inc
, which would be the expected effect:On the negative side, this solution may feel too hardcoded to me (when compared to entity_ui_get_form)...
On the plus side however, the developer implementing an entity can still override the ::view() method on his current entity controller:
I'm pretty sure there's better ways to do this, but at least for now that's what I did to solve this issue.
Comment #2
Alexander Allen CreditAttribution: Alexander Allen commentedNow that I've posted a temporary fix for myself, just thinking out loud - why can Drupal find entity_ui_get_form() without any issues, but it cannot find entity_ui_entity_page_view() ?
...
UPDATE: Answering myself: functions such as entity_ui_bundle_add_page() and entity_ui_get_form() - which are the ones used by the other default
::hook_menu()
items - reside inentity.module
. The functions there are available to other modules.entity_ui_entity_page_view() on the other hand resides in
entity.ui.inc
, which is not automatically loaded - hence why I get the WSOD. Both entity_ui_get_form() and entity_ui_bundle_add_page() do aform_load_include($form_state, 'inc', 'entity', 'includes/entity.ui')
, which is why they work - even when the'file'
parameter in the custom entity's'admin ui'
property and database menu router items point to the entity's *.admin.inc include file.If entity_ui_entity_page_view() is moved to entity.module, this issue should be fixed.
Comment #3
Alexander Allen CreditAttribution: Alexander Allen commentedAttached patch for comment #2 -
Moved entity_ui_entity_page_view() and entity_ui_get_page_title() to entity.module. Added a module_load_include() to both functions. Hope this works :)
Comment #5
Alexander Allen CreditAttribution: Alexander Allen commentedSubmitted the last patch using an absolute path, using relative now.
Comment #6
Alexander Allen CreditAttribution: Alexander Allen commentedComment #8
Alexander Allen CreditAttribution: Alexander Allen commentedLooks like a missing line at the end may cause the patch to fail.
Comment #9
Alexander Allen CreditAttribution: Alexander Allen commentedAdded patch metadata. Let me know if you want me to do something else.
Thanks
Comment #10
Alexander Allen CreditAttribution: Alexander Allen commentedFYI,
Screenshot of a test on a
admin/content/[entityType]/% path
path.I didn't see any notices on watchdog.
Comment #11
fagoIndeed - thanks for figuring this out. It was working for the while module only coincidentally (the while module specifieds a custom UI include file which triggers loading of entity.ui.inc via class auto-loading).
Committed.
Comment #12.0
(not verified) CreditAttribution: commentedAdd step to reproduce error.