Description of the need
Redirecting to a node or other entity page is unnecessarily cumbersome. Common approaches include:
// Manual assembly for known entity types:
backdrop_goto('node/' . $node->nid);
// Using URI for general entities:
$uri = $entity->uri();
backdrop_goto($uri['path'], $uri['options']);
// Trying to shorthand the above into a single line:
backdrop_goto($entity->uri()['path']);
Proposed solution
Create a short-hand wrapper function around backdrop_goto() that makes redirecting to entities easier.
function entity_goto(Entity $entity) {
$uri = $entity->uri();
backdrop_goto($uri['path'], $uri['options']);
}
Alternatives that have been considered
Maybe also create $entity->goto() method?
GitHub Issue #:
5838
Recent comments
Thanks, I have to go out now, I will try later on and report back
Importing the staged config throws an error: another field with the same name already exists
Hi Francis. Yes, what config do you have in staging for it? You might have configs like: field.field.field_video_embed field.instance.node.page....
Importing the staged config throws an error: another field with the same name already exists
Hi @yorkshirepudding! Nothing in admin/reports/fields or admin/config/development/configuration/single/export There is a field in the database though. Should I just copy the item...
Importing the staged config throws an error: another field with the same name already exists