Add a local task tab for a content type only Someone can help me ? I want to display a tab only when the content type is 'test'.

Here's my files.

mymodule.routing.yml :

mymodule.check_test:
  path: '/checktest/{node}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\CheckTestController::content'
  requirements:
    _access: 'TRUE'


mymodule.links.task.yml :

mymodule.check_test:
    title: Display tests
    route_name: mymodule.check_test
    base_route: entity.node.canonical


My tab is displayed for every content, i don't know how to filter with my content type...

Thanks :).

Edit :
From mradcliffe's answer,

I've add a mymodule.services.yml :

services:
  access_check.test:
    class: Drupal\mymodule\Access\MyModuleTestAccess
    tags:
      - { name: access_check, applies_to: _access_test }


and a MyModuleTestAccess class with :

public function access(NodeInterface $node)
{
    return AccessResult::allowedIf($node-&gt;bundle() === 'test');
}


My edited mymodule.routing.yml :

mymodule.check_test:
  path: '/checktest/{node}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\CheckTestController::content'
  requirements:
    _access_test: ''
You can use an access check to hide a route.

If the user that will view the tab has the same permission for adding a node of a given type, then simply adding _node_add_access: 'node:MYNODETYPEHERE' would be sufficient. However this is probably not the case.

Instead you can add _custom_access to the route requirements as a method on the controller class.

mymodule.check_test:
  path: '/checktest/{node}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\CheckTestController::content'
  requirements:
    _custom_access: '\Drupal\mymodule\Controller\CheckTestController::checkAccess'
    # It is highly-recommended to always use the default entity access check for
    # an Entity as pointed out by @pwolanin below. Not doing so may lead to
    # undesirable results and potential information disclosure or access bypass
    # vulnerability.
    _entity_access: node.view


And then a corresponding method on the controller (see Access checking on routes for more details). Something like this might work for you (untested).

public function checkAccess($node) {
  return AccessResult::allowedif($node-&gt;bundle() === 'my_node_type');
}


Update 2019.08.30: Incorporated @pwolanin's answer into this one in case anyone misses and doesn't read its importance.