Esi.php 1017 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\PageCache\Controller\Block;
  8. class Esi extends \Magento\PageCache\Controller\Block
  9. {
  10. /**
  11. * Returns block content as part of ESI request from Varnish
  12. *
  13. * @return void
  14. */
  15. public function execute()
  16. {
  17. $response = $this->getResponse();
  18. $blocks = $this->_getBlocks();
  19. $html = '';
  20. $ttl = 0;
  21. if (!empty($blocks)) {
  22. $blockInstance = array_shift($blocks);
  23. $html = $blockInstance->toHtml();
  24. $ttl = $blockInstance->getTtl();
  25. if ($blockInstance instanceof \Magento\Framework\DataObject\IdentityInterface) {
  26. $response->setHeader('X-Magento-Tags', implode(',', $blockInstance->getIdentities()));
  27. }
  28. }
  29. $this->translateInline->processResponseBody($html);
  30. $response->appendBody($html);
  31. $response->setPublicHeaders($ttl);
  32. }
  33. }