Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CmsPage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Sitemap\Model\ResourceModel\Cms\PageFactory;
10 use Magento\Sitemap\Model\SitemapItemInterfaceFactory;
11 
13 {
19  private $cmsPageFactory;
20 
26  private $itemFactory;
27 
33  private $configReader;
34 
42  public function __construct(
43  ConfigReaderInterface $configReader,
44  PageFactory $cmsPageFactory,
45  SitemapItemInterfaceFactory $itemFactory
46  ) {
47  $this->cmsPageFactory = $cmsPageFactory;
48  $this->itemFactory = $itemFactory;
49  $this->configReader = $configReader;
50  }
51 
55  public function getItems($storeId)
56  {
57  $collection = $this->cmsPageFactory->create()->getCollection($storeId);
58  $items = array_map(function ($item) use ($storeId) {
59  return $this->itemFactory->create([
60  'url' => $item->getUrl(),
61  'updatedAt' => $item->getUpdatedAt(),
62  'images' => $item->getImages(),
63  'priority' => $this->configReader->getPriority($storeId),
64  'changeFrequency' => $this->configReader->getChangeFrequency($storeId),
65  ]);
66  }, $collection);
67 
68  return $items;
69  }
70 }
__construct(ConfigReaderInterface $configReader, PageFactory $cmsPageFactory, SitemapItemInterfaceFactory $itemFactory)
Definition: CmsPage.php:42
$items