public function PixelSubscriber::onKernelResponse in Simple Facebook Pixel 8
Invalidates page cache tags if needed.
File
- src/
EventSubscriber/ PixelSubscriber.php, line 95
Class
- PixelSubscriber
- Class PixelSubscriber.
Namespace
Drupal\simple_facebook_pixel\EventSubscriberCode
public function onKernelResponse(FilterResponseEvent $event) {
$response = $event
->getResponse();
if (strpos($response
->getContent(), 'CompleteRegistration') !== FALSE) {
Cache::invalidateTags([
'simple_facebook_pixel:complete_registration',
]);
}
if (strpos($response
->getContent(), '"track", "AddToCart"') !== FALSE) {
Cache::invalidateTags([
'simple_facebook_pixel:add_to_cart',
]);
}
if (strpos($response
->getContent(), '"track", "AddToWishlist"') !== FALSE) {
Cache::invalidateTags([
'simple_facebook_pixel:add_to_wishlist',
]);
}
if (strpos($response
->getContent(), '"track", "Purchase"') !== FALSE) {
Cache::invalidateTags([
'simple_facebook_pixel:purchase',
]);
}
}