getTranslatorPermissions example

'id' => $this->bundle,
      'label' => $this->bundle,
      'revision' => FALSE,
    ]);
    $bundle->save();
  }

  /** * {@inheritdoc} */
  public function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()[
      'translate any entity',
      'access administration pages',
      'administer blocks',
      'administer block_content fields',
      'access block library',
      'create basic block content',
      'edit any basic block content',
      'delete any basic block content',
    ]);
  }

  

  protected function setUp(): void {
    // Use the entity_test_mul as this has multilingual property support.     $this->entityTypeId = 'entity_test_mul_changed';
    parent::setUp();
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer entity_test content', 'view test entity']);
  }

}

  protected function setUp(): void {
    $this->entityTypeId = 'shortcut';
    $this->bundle = 'default';
    parent::setUp();
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['access shortcuts', 'administer shortcuts', 'access toolbar']);
  }

  /** * {@inheritdoc} */
  protected function createEntity($values$langcode$bundle_name = NULL) {
    $values['link']['uri'] = 'internal:/user';
    return parent::createEntity($values$langcode$bundle_name);
  }

  /** * {@inheritdoc} */

  protected function getEditorPermissions() {
    // Every entity-type-specific test needs to define these.     return [];
  }

  /** * Returns an array of permissions needed for the administrator. */
  protected function getAdministratorPermissions() {
    return array_merge($this->getEditorPermissions()$this->getTranslatorPermissions()['administer languages', 'administer content translation']);
  }

  /** * Creates and activates translator, editor and admin users. */
  protected function setupUsers() {
    $this->translator = $this->drupalCreateUser($this->getTranslatorPermissions(), 'translator');
    $this->editor = $this->drupalCreateUser($this->getEditorPermissions(), 'editor');
    $this->administrator = $this->drupalCreateUser($this->getAdministratorPermissions(), 'administrator');
    $this->drupalLogin($this->translator);
  }

  

  protected function setUp(): void {
    $this->entityTypeId = 'menu_link_content';
    $this->bundle = 'menu_link_content';
    parent::setUp();
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer menu']);
  }

  /** * {@inheritdoc} */
  protected function getAdministratorPermissions() {
    return array_merge(parent::getAdministratorPermissions()['administer themes', 'view the administration theme']);
  }

  /** * {@inheritdoc} */
'vid' => $this->bundle,
      'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
      'weight' => mt_rand(0, 10),
    ]);
    $this->vocabulary->save();
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer taxonomy']);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    return ['name' => $this->randomMachineName()] + parent::getNewEntityValues($langcode);
  }

  /** * Returns an edit array containing the values to be posted. */
public function setupBundle() {
    $this->createMediaType('test', [
      'id' => $this->bundle,
      'queue_thumbnail_downloads' => FALSE,
    ]);
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()[
      'administer media',
      'edit any test media',
    ]);
  }

  /** * {@inheritdoc} */
  protected function getEditorPermissions() {
    return ['administer media', 'create test media'];
  }

  
$this->testLanguageSelector = FALSE;
    $this->name = $this->randomMachineName();
    parent::setUp();

    \Drupal::entityTypeManager()->getStorage('user')->resetCache();
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer users']);
  }

  /** * {@inheritdoc} */
  protected function getNewEntityValues($langcode) {
    // User name is not translatable hence we use a fixed value.     return ['name' => $this->name] + parent::getNewEntityValues($langcode);
  }

  /** * {@inheritdoc} */
/** * Returns an array of permissions needed for the entity owner. */
  protected function getEntityOwnerPermissions() {
    return ['edit own entity_test content', 'translate editable entities', 'view test entity', 'view test entity translations', 'view unpublished test entity translations'];
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    $permissions = parent::getTranslatorPermissions();
    $permissions[] = 'view test entity';
    $permissions[] = 'view test entity translations';
    $permissions[] = 'view unpublished test entity translations';

    return $permissions;
  }

  /** * {@inheritdoc} */
  protected function getEditorPermissions() {
    
    $user = User::load(2);
    $user->langcode = Language::LANGCODE_NOT_SPECIFIED;
    $user->save();

    ViewTestData::createTestViews(static::class['content_translation_test_views']);
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    $permissions = parent::getTranslatorPermissions();
    $permissions[] = 'access user profiles';
    return $permissions;
  }

  /** * Tests the content translation overview link field handler. */
  public function testTranslationLink() {
    $this->drupalGet('test-entity-translations-link');
    $this->assertSession()->linkByHrefExists('user/1/translations');
    $this->assertSession()->linkByHrefNotExists('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.');
  }
delete any {$this->bundle} content",
      "view {$this->bundle} revisions",
      "delete {$this->bundle} revisions",
    ];
    return array_merge($editor_permissions$this->commonPermissions);
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()$this->commonPermissions);
  }

  /** * {@inheritdoc} */
  protected function setupBundle() {
    parent::setupBundle();
    $this->createContentType(['type' => $this->bundle]);
    $this->createEditorialWorkflow();
  }

  
$storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    $translation = $entity->getTranslation($langcode);
    // Make sure we unpublished the node correctly.     $this->assertFalse($this->manager->getTranslationMetadata($translation)->isPublished(), 'The translation has been correctly unpublished.');
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['administer nodes', "edit any $this->bundle content"]);
  }

  /** * {@inheritdoc} */
  protected function getEditorPermissions() {
    return ['administer nodes', 'create article content'];
  }

  /** * {@inheritdoc} */
$assert_session->pageTextContains('Powered by Drupal');
    $assert_session->linkNotExists('Layout');

    $this->drupalGet($translated_layout_url);
    $assert_session->pageTextContains('Access denied');
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    $permissions = parent::getTranslatorPermissions();
    $permissions[] = 'view test entity translations';
    $permissions[] = 'view test entity';
    $permissions[] = 'configure any layout';
    return $permissions;
  }

  /** * Setup translated entity with layouts. */
  protected function setUpEntities() {
    $this->drupalLogin($this->administrator);

    
// Add a comment field to the page content type - this one won't be     // translatable.     $this->addDefaultCommentField('node', 'page', 'comment');
    // Mark this bundle as translatable.     $this->container->get('content_translation.manager')->setEnabled('comment', 'comment_article', TRUE);
  }

  /** * {@inheritdoc} */
  protected function getTranslatorPermissions() {
    return array_merge(parent::getTranslatorPermissions()['post comments', 'administer comments', 'access comments']);
  }

  /** * {@inheritdoc} */
  protected function createEntity($values$langcode$comment_type = 'comment_article') {
    if ($comment_type == 'comment_article') {
      // This is the article node type, with the 'comment_article' field.       $node_type = 'article';
      $field_name = 'comment_article';
    }
    
Home | Imprint | This part of the site doesn't use cookies.