Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I use this module for an installation profile.
When I tried to install my profile I got this error message:
[error] The Drupal\menu_link_content\Entity\MenuLinkContent class does not correspond to an entity type.
I figured out that the problem is in the registration_link.install file, because it looks like this:
use Drupal\menu_link_content\Entity\MenuLinkContent;
MenuLinkContent::create([
'title' => 'Register an Account',
'link' => ['uri' => 'route:registration_link.register'],
'menu_name' => 'account',
'weight' => 10,
])->save();
So in this .install file, the module should implement the hook_install() hook to do installation tasks.
When I updated the code, the module can be successfully installed by my installation profile:
use Drupal\menu_link_content\Entity\MenuLinkContent;
/**
* Implements hook_install().
*/
function registration_link_install()
{
MenuLinkContent::create([
'title' => 'Register an Account',
'link' => ['uri' => 'route:registration_link.register'],
'menu_name' => 'account',
'weight' => 10,
])->save();
}
Comment | File | Size | Author |
---|---|---|---|
#2 | registration_link_install_2944072_2.patch | 1.02 KB | nkoporec |
Comments
Comment #2
nkoporecYeah, this should be in hook_install().Created a patch to fix this issue.
Comment #3
i-trokhanenkoPatch 2 works well for me. Thanks.
Comment #4
gisleChanging priority.
Comment #6
i-trokhanenkoCommitted!