Defining local actions

Nothing about our Hello World module calls for defining a local action link. So instead of doing that, let's check out one that actually makes sense. If you navigate to the admin/content screen, you'll see the + Add content button. It looks exactly the same as the example we saw earlier on the user management page. That is a local action link for this route. The + styling indicates that these links are primarily used to add or create new items relevant to the current route.

This particular local action link is defined in the node module inside the node.links.action.yml file, and it looks like this:

node.add_page:
route_name: node.add_page
title: 'Add content'
appears_on:
- system.admin_content

Again, we have the machine name (plugin ID) and the definition. I hope that route_name and title are, by now, clear to you. A new thing here, though, is the appears_on key that is used to indicate the routes (plural) on which this action link should show up. So, a key feature is that one action link can exist on multiple pages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset