While upgrading plugins to 1.12 from 1.8, I came across the issue where "page_handler" is removed from 1.12. Is there any good alternative for this method available in Elgg at the moment? Currently I've replaced it with something that uses internal Elgg methods:
// Get all registered page handelers
$handlers = _elgg_services()->router->getPageHandlers();
// Check if the page handlers exists
if (isset($handlers['{identifier}'])) {
// Get handler function
$handler = $handlers['{identifier}'];
// Execute the page handler
$handled = call_user_func($handler, array(
{url parts}
), '{indentifier}');
// Check if it succeeds
if (!$handled) {
// some (custom) error handling going on here..
}
} else {
// some (custom) error handling going on here..
}
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Juho Jaakkola@juho.jaakkola
Juho Jaakkola - 0 likes
- Wouter van Os@Wouter0100
Wouter van Os - 0 likes
- Wouter van Os@Wouter0100
Wouter van Os - 0 likes
- Steve Clay@steve_clay
Steve Clay - 0 likes
- Wouter van Os@Wouter0100
Wouter van Os - 0 likes
You must log in to post replies.Do you mean that a function called page_handler() has been removed? I'm not aware of function like that ever existing. Could you provide more details?
Yeah, I'm not sure if we were allowed to use it, but it was a really handy function for this plugin. It executed the page handler for a given URL. It was used in Elgg 1.8 core in the engine/handlers/page_handlers.php-file. The function was defined in engine/lib/pagehandler.php.
Ah, wait. Is this just changed to `_elgg_services()->router->route();`?
Yeah, it seems like. But that method takes a Request object, but not a simple identifier and path.
page_handler() was marked private in 1.8.1, but obviously that was easy for devs to miss. We prefix all new private functions with _. Being private API, we refactored it a few times over the years.
You might be able to hack a legacy handler together:
Hmm, thanks. In that case I'll look into creating something easy for this..