PostList.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Block\Amp\Ldjson;
  9. /**
  10. * Blog post list ldJson block
  11. */
  12. if (class_exists('\Plumrocket\Amp\Block\Page\Head\Ldjson\Cms')) {
  13. class PostListIntermediate extends \Plumrocket\Amp\Block\Page\Head\Ldjson\Cms {}
  14. } else {
  15. class PostListIntermediate extends \Magento\Framework\View\Element\AbstractBlock {}
  16. }
  17. class PostList extends PostListIntermediate
  18. {
  19. /**
  20. * Retrieve page structure structure data in JSON
  21. *
  22. * @return string
  23. */
  24. public function getJson()
  25. {
  26. $time = time();
  27. if (!$this->_cmsPage->getCreationTime()) {
  28. $this->_cmsPage->setCreationTime(
  29. date('Y-m-01 00:00:00', $time - 86400 * 150)
  30. );
  31. }
  32. if (!$this->_cmsPage->getUpdateTime()) {
  33. $this->_cmsPage->setUpdateTime(
  34. date('Y-m-01 00:00:00', $time)
  35. );
  36. }
  37. if (!$this->_cmsPage->getTitle()) {
  38. $this->_cmsPage->setTitle(
  39. $this->pageConfig->getTitle()->get()
  40. );
  41. }
  42. return parent::getJson();
  43. }
  44. }