Completed
Pull Request — 8.x-3.x (#525)
by Philipp
02:33
created

CacheablePluginTrait::buildCacheMetadata()   B

Complexity

Conditions 7
Paths 64

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 8
nc 64
nop 1
dl 0
loc 10
rs 8.2222
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\graphql\Plugin\GraphQL\Traits;
4
5
use Drupal\Core\Cache\CacheBackendInterface;
6
7
trait CacheablePluginTrait {
8
9
  /**
10
   * @param $definition
11
   *
12
   * @return array
13
   */
14
  protected function buildCacheMetadata($definition) {
15
    return [
16
      'schema_cache_contexts' => isset($definition['schema_cache_contexts']) ? $definition['schema_cache_contexts'] : ['languages:language_interface'],
17
      'schema_cache_tags' => isset($definition['schema_cache_tags']) ? $definition['schema_cache_tags'] : [],
18
      'schema_cache_max_age' => isset($definition['schema_cache_max_age']) ? $definition['schema_cache_max_age'] : CacheBackendInterface::CACHE_PERMANENT,
19
      'response_cache_contexts' => isset($definition['response_cache_contexts']) ? $definition['response_cache_contexts'] : ['user.permissions'],
20
      'response_cache_tags' => isset($definition['response_cache_tags']) ? $definition['response_cache_tags'] : [],
21
      'response_cache_max_age' => isset($definition['response_cache_max_age']) ? $definition['response_cache_max_age'] : CacheBackendInterface::CACHE_PERMANENT,
22
    ];
23
  }
24
}
25