getEditorialPermissions example

return "The following permissions are required: 'delete any media' OR 'delete own media' OR 'camelids: delete any media' OR 'camelids: delete own media'.";

      default:
        return '';
    }
  }

  /** * {@inheritdoc} */
  protected function getEditorialPermissions() {
    return array_merge(parent::getEditorialPermissions()['view any unpublished content']);
  }

  /** * {@inheritdoc} */
  protected function getExpectedUnauthorizedAccessCacheability() {
    // @see \Drupal\media\MediaAccessControlHandler::checkAccess()     return parent::getExpectedUnauthorizedAccessCacheability()
      ->addCacheTags(['media:1']);
  }

  
$expected_response = static::getExpectedCollectionResponse([$entity]$rel_working_copy_collection_url->toString()$request_options);
      $expected_collection_document = $expected_response->getResponseData();
      $expected_collection_document['data'] = [];
      $expected_cacheability = $expected_response->getCacheableMetadata();
      $access_denied_response = static::getAccessDeniedResponse($entity$result$url, NULL, $detail)->getResponseData();
      static::addOmittedObject($expected_collection_documentstatic::errorsToOmittedObject($access_denied_response['errors']));
      $this->assertResourceResponse(200, $expected_collection_document$actual_response$expected_cacheability->getCacheTags()$expected_cacheability->getCacheContexts(), FALSE, 'MISS');
    }

    // Since additional permissions are required to see 'draft' entities,     // grant those permissions.     $this->grantPermissionsToTestedRole($this->getEditorialPermissions());

    // Now, the `working-copy` link should be latest revision and be accessible.     $actual_response = $this->request('GET', $rel_working_copy_url$request_options);
    $expected_document['data']['attributes'][$revision_id_key] = $forward_revision_id;
    $expected_document['data']['attributes']['moderation_state'] = 'draft';
    $expected_document['data']['attributes'][$published_key] = FALSE;
    $expected_document['data']['attributes']['field_revisionable_number'] = 42;
    $expected_document['links']['self']['href'] = $rel_working_copy_url->setAbsolute()->toString();
    $expected_document['data']['attributes'][$revision_translation_affected_key] = $entity->isRevisionTranslationAffected();
    // The resource object now must link to the forward revision.     $forward_revision_id_url = clone $url;
    
Home | Imprint | This part of the site doesn't use cookies.