Problem/Motivation
According to the class code comment, this is the property of the link property on an instance of a MenuLinkContent:
@property \Drupal\link\LinkItemInterface $link
This seems to not be the case. It's in fact a Drupal\Core\Field\FieldItemList so basically a list of Drupal\link\Plugin\Field\FieldType\LinkItem objects. Or a list of LinkItemInterface if you want.
To verify this in a clean install of Drupal 10.1.x I did the following:
- Installed the standard profile
- Created a menu link
- Ran the script below
<?php
use Drupal\menu_link_content\Entity\MenuLinkContent;
// The link with an ID of 1 is the one I just created.
$link = MenuLinkContent::load(1);
var_dump([
get_class($link),
get_class($link->link),
get_class($link->link->first()),
]);
The output was as follows:
array(3) {
[0]=>
string(47) "Drupal\menu_link_content\Entity\MenuLinkContent"
[1]=>
string(31) "Drupal\Core\Field\FieldItemList"
[2]=>
string(43) "Drupal\link\Plugin\Field\FieldType\LinkItem"
}
Steps to reproduce
See above
Proposed resolution
Change the doc comment
Remaining tasks
Agree on this
Commit
User interface changes
none
API changes
none
Data model changes
none
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3364867.patch | 577 bytes | eiriksm |
Issue fork drupal-3364867
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
eiriksmWaiting for the issue fork. Here is a patch
Comment #4
eiriksmAh, there it was. Sorry for the double MR and patch. They should be the same though
Comment #5
smustgrave commentedSimple change looks good.
Comment #6
longwaveCommitted and pushed c1b8fdd9d9 to 11.x and 69e1c13c5a to 10.1.x. Thanks!