content_translation_translate_access example

'#theme' => 'links__comment__comment',
      // The "entity" property is specified to be present, so no need to check.       '#links' => $links,
      '#attributes' => ['class' => ['links', 'inline']],
    ];
  }

  /** * Wraps content_translation_translate_access. */
  protected function access(EntityInterface $entity) {
    return content_translation_translate_access($entity);
  }

  /** * {@inheritdoc} */
  public static function trustedCallbacks() {
    return ['renderLinks', 'renderForm'];
  }

}
/** * Tests the access to the overview page for translations. * * @see content_translation_translate_access() */
  public function testContentTranslationOverviewAccess() {
    $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node');
    $user = $this->createUser(['create content translations', 'access content']);
    $this->drupalLogin($user);

    $node = $this->drupalCreateNode(['status' => FALSE, 'type' => 'article']);
    $this->assertFalse(content_translation_translate_access($node)->isAllowed());
    $access_control_handler->resetCache();

    $node->setPublished();
    $node->save();
    $this->assertTrue(content_translation_translate_access($node)->isAllowed());
    $access_control_handler->resetCache();

    user_role_change_permissions(
      Role::AUTHENTICATED_ID,
      [
        'access content' => FALSE,
      ]
Home | Imprint | This part of the site doesn't use cookies.