getSparseFieldSets example


  protected function getExpectedUnauthorizedAccessMessage($method) {
    return "The 'administer entity_test content' permission is required.";
  }

  /** * {@inheritdoc} */
  protected function getSparseFieldSets() {
    // EntityTestMapField's owner field name is `user_id`, not `uid`, which     // breaks nested sparse fieldset tests.     return array_diff_key(parent::getSparseFieldSets()array_flip([
      'nested_empty_fieldset',
      'nested_fieldset_with_owner_fieldset',
    ]));
  }

}

      ],
    ];
  }

  /** * {@inheritdoc} */
  protected function getSparseFieldSets() {
    // EntityTest's owner field name is `user_id`, not `uid`, which breaks     // nested sparse fieldset tests.     return array_diff_key(parent::getSparseFieldSets()array_flip([
      'nested_empty_fieldset',
      'nested_fieldset_with_owner_fieldset',
    ]));
  }

  protected function getExpectedCacheContexts(array $sparse_fieldset = NULL) {
    $cache_contexts = parent::getExpectedCacheContexts($sparse_fieldset);
    if ($sparse_fieldset === NULL || in_array('computed_test_cacheable_string_field', $sparse_fieldset)) {
      $cache_contexts = Cache::mergeContexts($cache_contexts['url.query_args:computed_test_cacheable_string_field']);
    }

    
/** * Tests sparse field sets. * * @param \Drupal\Core\Url $url * The base URL with which to test includes. * @param array $request_options * Request options to apply. * * @see \GuzzleHttp\ClientInterface::request() */
  protected function doTestSparseFieldSets(Url $url, array $request_options) {
    $field_sets = $this->getSparseFieldSets();
    $expected_cacheability = new CacheableMetadata();
    foreach ($field_sets as $type => $field_set) {
      if ($type === 'all') {
        assert($this->getExpectedCacheTags($field_set) === $this->getExpectedCacheTags());
        assert($this->getExpectedCacheContexts($field_set) === $this->getExpectedCacheContexts());
      }
      $query = ['fields[' . static::$resourceTypeName . ']' => implode(',', $field_set)];
      $expected_document = $this->getExpectedDocument();
      $expected_cacheability->setCacheTags($this->getExpectedCacheTags($field_set));
      $expected_cacheability->setCacheContexts($this->getExpectedCacheContexts($field_set));
      // This tests sparse field sets on included entities.
default:
        return parent::getExpectedUnauthorizedAccessMessage($method);
    }
  }

  /** * {@inheritdoc} */
  protected function getSparseFieldSets() {
    // EntityTest's owner field name is `user_id`, not `uid`, which breaks     // nested sparse fieldset tests.     return array_diff_key(parent::getSparseFieldSets()array_flip([
      'nested_empty_fieldset',
      'nested_fieldset_with_owner_fieldset',
    ]));
  }

  /** * {@inheritdoc} */
  protected static function getExpectedCollectionCacheability(AccountInterface $account, array $collection, array $sparse_fieldset = NULL, $filtered = FALSE) {
    $cacheability = parent::getExpectedCollectionCacheability($account$collection$sparse_fieldset$filtered);
    if ($filtered) {
      
Home | Imprint | This part of the site doesn't use cookies.