Unverified Commit 77cf0e3e authored by ndobromirov's avatar ndobromirov Committed by e0ipso

Issue #3019729 by ndobromirov, Wim Leers, rhristov, e0ipso: Invalidate...

Issue #3019729 by ndobromirov, Wim Leers, rhristov, e0ipso: Invalidate JSON:API Extras' cache tags when needed
parent 5a6bc98e
......@@ -9,6 +9,10 @@ use Drupal\jsonapi\ResourceType\ResourceTypeRepository;
use Drupal\jsonapi_extras\Entity\JsonapiResourceConfig;
use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerManager;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Cache\CacheBackendInterface;
/**
* Provides a repository of JSON:API configurable resource types.
......@@ -57,15 +61,6 @@ class ConfigurableResourceTypeRepository extends ResourceTypeRepository {
*/
protected $resourceConfigs;
/**
* {@inheritdoc}
*/
protected $cacheTags = [
'jsonapi_resource_types',
'config:jsonapi_extras.settings',
'config:jsonapi_resource_config_list',
];
/**
* Builds the resource config ID from the entity type ID and bundle.
*
......@@ -85,6 +80,27 @@ class ConfigurableResourceTypeRepository extends ResourceTypeRepository {
);
}
/**
* {@inheritdoc}
*/
public function __construct(
EntityTypeManagerInterface $entity_type_manager,
EntityTypeBundleInfoInterface $entity_bundle_info,
EntityFieldManagerInterface $entity_field_manager,
CacheBackendInterface $cache
) {
parent::__construct($entity_type_manager, $entity_bundle_info, $entity_field_manager, $cache);
// This is needed, as the property is added in Drupal 8.8 and it is not
// yet present in 8.7 or the contrib version of JSON:API at the time.
if (property_exists($this, 'cacheTags')) {
$this->cacheTags = array_merge($this->cacheTags, [
'config:jsonapi_extras.settings',
'config:jsonapi_resource_config_list',
]);
}
}
/**
* Injects the entity repository.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment