Help - Using 'handler' in entity menu parameters is deprecated (Elgg 3.0 RC2)

I am trying to upgrade some of my plugin to support 3.0 and I am stuck with the following Warning
 
ELGG.WARNING: Deprecated in 3.0: Using 'handler' in entity menu parameters is deprecated. Use named routes instead.
 
Here are 3 of the cases for which the warning is getting generated:
 
elgg_view_menu('entity', [
 'entity' => elgg_extract('entity', $vars),
 'handler' => elgg_extract('handler', $vars),
]);
elgg_view_menu('entity', [
 'entity' => $entity,
 'sort_by' => 'priority',
 'class' => 'elgg-menu-hz',
 'handler' => 'market',
]);
elgg_view_menu('entity', [
 'entity' => $entity,
 'sort_by' => 'priority',
 'class' => 'elgg-menu-hz',
 'handler' => 'market',
]);
I have searched all the doc and guide but not able to find any good reference on how to fix this issue for Elgg 3.0.
 
Can anyone help me what exactly needs to be done for this?
  • You don't need to create the entity's menu in this case.

    Just call routes of this object in elgg-plugin.php:

    return [
        'entities' => [
            [
                'type' => 'object',
                'subtype' => 'market',
                'searchable' => true,
            ],
        ],
        'routes' => [
            'default:object:market' => [
                'path' => '/market',
                'resource' => 'market/all',
            ],
            'collection:object:market:all' => [
                'path' => '/market/all',
                'resource' => 'market/all',
            ],
            'collection:object:market:owner' => [
                'path' => '/market/owner/{username}',
                'resource' => 'market/owner',
            ],
            'collection:object:market:friends' => [
                'path' => '/market/friends/{username}',
                'resource' => 'market/friends',
            ],
            'view:object:market' => [
                'path' => '/market/view/{guid}',
                'resource' => 'market/view',
            ],
        ],
    ];

    You can add more routes if you want.

    If you want to extend the entity' menu then register plugin hook handlers in your classes:

    In Bootstrap:

    protected function registerHooks() {
        $hooks = $this->elgg()->hooks;
        $hooks->registerHandler('register', 'menu:entity', __NAMESPACE__ . '\Menus::entityExtend');
    }

    In Menus:

    public static function entityExtend($hook, $type, $return, $params) {
            
        $entity = elgg_extract('entity', $params);
    
        $return[] = \ElggMenuItem::factory([
            'name' => 'market-extend',
            'text' => elgg_echo('market:extend'),
            'href' => 'market/extend',
            'priority' => 200,
        ]);
            
        return $return;
    }