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.
By tim.plunkett on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Description:
In Drupal 7, the Field UI supported different paths per-bundle for its "Manage Fields" and "Manage Display" functionality.
function node_entity_info() {
// Bundles must provide a human readable name so we can create help and error
// messages, and the path to attach Field admin pages to.
foreach (node_type_get_names() as $type => $name) {
$return['node']['bundles'][$type] = array(
'label' => $name,
'admin' => array(
'path' => 'admin/structure/types/manage/%node_type',
'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type),
'bundle argument' => 4,
'access arguments' => array('administer content types'),
),
);
}
}
This has moved directly to the entity type's annotation:
/**
* Defines the node entity class.
*
* @EntityType(
* id = "node",
* label = @Translation("Content"),
* // ...
* route_base_path = "admin/structure/types/manage/{bundle}"
*/
class Node extends ContentEntityBase implements NodeInterface {
}
In the case of more complex UI paths, like in Comment module where the Comment Field UI was placed at the same level as the Node Field UI, you are able to specify a s "bundle prefix":
/**
* @EntityType(
* id = "comment",
* label = @Translation("Comment"),
* // …
* route_base_path = "admin/structure/types/manage/{bundle}/comment",
* bundle_prefix = "comment_node_" * )
*/
class Comment extends ContentEntityBase implements CommentInterface {
}
For a comment bundle named 'article', this would generate a path of admin/structure/types/manage/comment_node_article/comment
.
Impacts:
Module developers