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();
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

david.czinege created an issue. See original summary.

nkoporec’s picture

Assigned: david.czinege » Unassigned
Status: Active » Needs review
FileSize
1.02 KB

Yeah, this should be in hook_install().Created a patch to fix this issue.

i-trokhanenko’s picture

Version: 8.x-1.0 » 8.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Patch 2 works well for me. Thanks.

gisle’s picture

Priority: Normal » Major

Changing priority.

i-trokhanenko’s picture

Status: Reviewed & tested by the community » Fixed

Committed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.