Skip to content

Commit a1a623e

Browse files
author
bohdan
committed
rename files
1 parent 060c9da commit a1a623e

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

Model/Sitemap/SitepamManagent.php renamed to Api/SitemapConfigInterface.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
* Glory to Ukraine! Glory to the heroes!
77
*/
88

9-
namespace Magefan\Blog\Model\Sitemap;
9+
namespace Magefan\Blog\Api;
1010

11-
12-
interface SitepamManagent
11+
interface SitemapConfigInterface
1312
{
13+
const HOME_PAGE = 'index';
14+
const CATEGORIES_PAGE = 'category';
15+
const POSTS_PAGE = 'post';
1416
/**
1517
* @param $page
1618
* @return bool

Model/Sitemap.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Magefan\Blog\Model;
1010

1111
use Magento\Framework\App\ProductMetadataInterface;
12-
use Magefan\Blog\Model\Sitemap\SitepamManagent;
12+
use Magefan\Blog\Api\SitemapConfigInterface;
1313

1414
/**
1515
* Deprecated
@@ -26,39 +26,40 @@ class Sitemap extends \Magento\Sitemap\Model\Sitemap
2626
protected function _initSitemapItems()
2727
{
2828

29+
2930
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
3031

3132
$megento = $objectManager->create(ProductMetadataInterface::class);
32-
$sitemapManagent = $objectManager->create(SitepamManagent::class);
33+
$sitemapConfig = $objectManager->create(SitemapConfigInterface::class);
3334

3435

3536
parent::_initSitemapItems();
3637

3738
$sitemapItems = [];
38-
if ($sitemapManagent->isEnabledSitemap('index_page')) {
39+
if ($sitemapConfig->isEnabledSitemap('index_page')) {
3940
$sitemapItems[] = new \Magento\Framework\DataObject(
4041
[
41-
'changefreq' => $sitemapManagent->getFrequency('index_page'),
42-
'priority' => $sitemapManagent->getPriority('index_page'),
42+
'changefreq' => $sitemapConfig->getFrequency(SitemapConfigInterface::HOME_PAGE),
43+
'priority' => $sitemapConfig->getPriority(SitemapConfigInterface::HOME_PAGE),
4344
'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create(
4445
\Magento\Framework\Data\Collection::class
4546
)->addItem(
4647
\Magento\Framework\App\ObjectManager::getInstance()->create(
4748
\Magento\Framework\DataObject::class
4849
)->setData([
49-
'updatedAt' => '2019-20-16',
50+
'updated_at' => '',
5051
'url' => '',
5152
])
5253
)
5354
]
5455
);
5556
}
5657

57-
if ($sitemapManagent->isEnabledSitemap('categories_pages')) {
58+
if ($sitemapConfig->isEnabledSitemap('categories_pages')) {
5859
$sitemapItems[] = new \Magento\Framework\DataObject(
5960
[
60-
'changefreq' => $sitemapManagent->getFrequency('categories_pages'),
61-
'priority' => $sitemapManagent->getPriority('categories_pages'),
61+
'changefreq' => $sitemapConfig->getFrequency(SitemapConfigInterface::CATEGORIES_PAGE),
62+
'priority' => $sitemapConfig->getPriority(SitemapConfigInterface::CATEGORIES_PAGE),
6263
'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create(
6364
\Magefan\Blog\Model\Category::class
6465
)->getCollection($this->getStoreId())
@@ -68,11 +69,11 @@ protected function _initSitemapItems()
6869
);
6970
}
7071

71-
if ($sitemapManagent->isEnabledSitemap('posts_pages')) {
72+
if ($sitemapConfig->isEnabledSitemap('posts_pages')) {
7273
$sitemapItems[] = new \Magento\Framework\DataObject(
7374
[
74-
'changefreq' => $sitemapManagent->getFrequency('posts_pages'),
75-
'priority' => $sitemapManagent->getPriority('posts_pages'),
75+
'changefreq' => $sitemapConfig->getFrequency(SitemapConfigInterface::POSTS_PAGE),
76+
'priority' => $sitemapConfig->getPriority(SitemapConfigInterface::POSTS_PAGE),
7677
'collection' => \Magento\Framework\App\ObjectManager::getInstance()->create(
7778
\Magefan\Blog\Model\Post::class
7879
)->getCollection($this->getStoreId())

Model/Sitemap/SitemapConfig.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<?php
22
/**
3-
* Created by PhpStorm.
4-
* User: dev4
5-
* Date: 06.02.19
6-
* Time: 9:52
3+
* Copyright © Magefan ([email protected]). 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!
77
*/
88

99
namespace Magefan\Blog\Model\Sitemap;
1010

11+
use Magefan\Blog\Api\SitemapConfigInterface;
1112

12-
class SitemapConfig implements SitepamManagent
13+
class SitemapConfig implements SitemapConfigInterface
1314
{
1415

1516
/**
@@ -28,13 +29,13 @@ public function isEnabledSitemap($page)
2829
public function getFrequency($page)
2930
{
3031
switch ($page) {
31-
case 'index_page':
32+
case 'index':
3233
$frequency = 'Dailly';
3334
break;
34-
case 'categories_pages':
35+
case 'category':
3536
$frequency = 'Dailly';
3637
break;
37-
case 'posts_pages':
38+
case 'post':
3839
$frequency = 'Dailly';
3940
break;
4041
default:
@@ -51,13 +52,13 @@ public function getPriority($page)
5152
{
5253

5354
switch ($page) {
54-
case 'index_page':
55+
case 'index':
5556
$priority = 1;
5657
break;
57-
case 'categories_pages':
58+
case 'category':
5859
$priority = 0.75;
5960
break;
60-
case 'posts_pages':
61+
case 'post':
6162
$priority = 0.5;
6263
break;
6364
default:

etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
-->
1010
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
1111

12-
<preference for="Magefan\Blog\Model\Sitemap\SitepamManagent" type="Magefan\Blog\Model\Sitemap\SitemapConfig" />
12+
<preference for="Magefan\Blog\Api\SitemapConfigInterface" type="Magefan\Blog\Model\Sitemap\SitemapConfig" />
1313
<preference for="Magefan\Blog\Api\PostManagementInterface" type="Magefan\Blog\Model\PostManagement" />
1414
<preference for="Magefan\Blog\Api\CategoryManagementInterface" type="Magefan\Blog\Model\CategoryManagement" />
1515
<!-- deprecated <preference for="Magento\Sitemap\Model\Sitemap" type="Magefan\Blog\Model\Sitemap" /> -->

0 commit comments

Comments
 (0)