diff --git a/src/Plugin/resource/DataProvider/CacheDecoratedDataProvider.php b/src/Plugin/resource/DataProvider/CacheDecoratedDataProvider.php index 99ac5893..a39e8eec 100644 --- a/src/Plugin/resource/DataProvider/CacheDecoratedDataProvider.php +++ b/src/Plugin/resource/DataProvider/CacheDecoratedDataProvider.php @@ -175,7 +175,16 @@ public function count() { * {@inheritdoc} */ public function create($object) { - return $this->subject->create($object); + $return = $this->subject->create($object); + $resource_field_collection = reset($return); + + if (!$resource_field_collection instanceof ResourceFieldCollectionInterface) { + return NULL; + } + + $interpreter = $resource_field_collection->getInterpreter(); + $resource_field_collection->setContext('cache_fragments', $this->getCacheFragments($resource_field_collection->getIdField()->value($interpreter))); + return $return; } /** @@ -216,7 +225,15 @@ public function viewMultiple(array $identifiers) { */ public function update($identifier, $object, $replace = TRUE) { $this->clearRenderedCache($this->getCacheFragments($identifier)); - return $this->subject->update($identifier, $object, $replace); + $return = $this->subject->update($identifier, $object, $replace); + $resource_field_collection = reset($return); + + if (!$resource_field_collection instanceof ResourceFieldCollectionInterface) { + return NULL; + } + + $resource_field_collection->setContext('cache_fragments', $this->getCacheFragments($identifier)); + return $return; } /** diff --git a/src/Plugin/resource/Decorators/CacheDecoratedResource.php b/src/Plugin/resource/Decorators/CacheDecoratedResource.php index b504f9e4..3f69a7e2 100644 --- a/src/Plugin/resource/Decorators/CacheDecoratedResource.php +++ b/src/Plugin/resource/Decorators/CacheDecoratedResource.php @@ -202,13 +202,22 @@ public function index($path) { return $this->getDataProvider()->index(); } + /** + * {@inheritdoc} + */ + public function create($path) { + $object = $this->getRequest()->getParsedBody(); + return $this->getDataProvider()->create($object); + } + /** * {@inheritdoc} */ public function update($path) { $this->invalidateResourceCache($path); // Update according to the decorated. - return $this->subject->update($path); + $object = $this->getRequest()->getParsedBody(); + return $this->getDataProvider()->update($path, $object, FALSE); } /**