Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Aug 25, 2020
2 parents 8493f9a + 76134b5 commit 23abe5d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<a name="2.4.0"></a>
# [2.4.0](https://github.com/flextype-plugins/sitemap/compare/v2.3.0...v2.4.0) (2020-08-25)

### Features

* **core** update code base for new Flextype 0.9.11

<a name="2.3.0"></a>
# [2.3.0](https://github.com/flextype-plugins/sitemap/compare/v2.2.0...v2.3.0) (2020-08-19)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">Sitemap Plugin for <a href="https://flextype.org/">Flextype</a></h1>

<p align="center">
<a href="https://github.com/flextype-plugins/themes-admin/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/sitemap.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/sitemap"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/sitemap"><img src="https://img.shields.io/github/downloads/flextype-plugins/sitemap/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.10-green.svg?color=black" alt="Flextype"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&color=black&label=Discord%20Chat" alt="Discord"></a>
<a href="https://github.com/flextype-plugins/themes-admin/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/sitemap.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/sitemap"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/sitemap"><img src="https://img.shields.io/github/downloads/flextype-plugins/sitemap/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.11-green.svg?color=black" alt="Flextype"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&color=black&label=Discord%20Chat" alt="Discord"></a>
</p>

Sitemap plugin provide automatically generated XML sitemap for Flextype.
Expand All @@ -12,7 +12,7 @@ The following dependencies need to be downloaded and installed for Sitemap Plugi

| Item | Version | Download |
|---|---|---|
| [flextype](https://github.com/flextype/flextype) | 0.9.10 | [download](https://github.com/flextype/flextype/releases) |
| [flextype](https://github.com/flextype/flextype) | 0.9.11 | [download](https://github.com/flextype/flextype/releases) |
| [twig](https://github.com/flextype-plugins/twig) | >=1.0.0 | [download](https://github.com/flextype-plugins/twig/releases) |

## Installation
Expand Down Expand Up @@ -74,8 +74,8 @@ additions:
### Dynamically adding entry(entries) to the sitemap
```php
$flextype->container('emitter')->addListener('onSitemapAfterInitialized', function() use ($flextype) {
$flextype->SitemapController->sitemap[] = ['loc' => 'something-special-to-add',
flextype('emitter')->addListener('onSitemapAfterInitialized', function() {
flextype('SitemapController')->sitemap[] = ['loc' => 'something-special-to-add',
'lastmod' => '03-07-2020 09:46',
'changefreq' => 'daily',
'priority' => 1.0];
Expand Down
27 changes: 11 additions & 16 deletions app/Controllers/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class SitemapController {

/**
* Flextype Application
*/
protected $flextype;

class SitemapController
{
/**
* Current $sitemap data array
*
Expand All @@ -26,9 +21,9 @@ class SitemapController {
*
* @access public
*/
public function __construct($flextype)
public function __construct()
{
$this->flextype = $flextype;

}

/**
Expand All @@ -42,7 +37,7 @@ public function index(Request $request, Response $response) : Response
{
$sitemap = [];

$entries = collect($this->flextype->container('entries')->fetchCollection('', ['depth' => '>0']))->orderBy('modified_at', 'ASC')->all();
$entries = collect(flextype('entries')->fetchCollection('', ['depth' => '>0']))->orderBy('modified_at', 'ASC')->all();

foreach ($entries as $entry) {

Expand All @@ -65,18 +60,18 @@ public function index(Request $request, Response $response) : Response
if (isset($entry['sitemap']['changefreq'])) {
$entry['changefreq'] = $entry['sitemap']['changefreq'];
} else {
$entry['changefreq'] = $this->flextype->container('registry')->get('plugins.sitemap.settings.default.changefreq');
$entry['changefreq'] = flextype('registry')->get('plugins.sitemap.settings.default.changefreq');
}

// Check entry priority field
if (isset($entry['sitemap']['priority'])) {
$entry['priority'] = $entry['sitemap']['priority'];
} else {
$entry['priority'] = $this->flextype->container('registry')->get('plugins.sitemap.settings.default.priority');
$entry['priority'] = flextype('registry')->get('plugins.sitemap.settings.default.priority');
}

// Check ignore list
if (in_array($entry['id'], (array) $this->flextype->container('registry')->get('plugins.sitemap.settings.ignore'))) {
if (in_array($entry['id'], (array) flextype('registry')->get('plugins.sitemap.settings.ignore'))) {
continue;
}

Expand All @@ -91,7 +86,7 @@ public function index(Request $request, Response $response) : Response
}

// Additions
$additions = (array) $this->flextype->container('registry')->get('plugins.sitemap.settings.additions');
$additions = (array) flextype('registry')->get('plugins.sitemap.settings.additions');
foreach ($additions as $addition) {
$sitemap[] = $addition;
}
Expand All @@ -100,12 +95,12 @@ public function index(Request $request, Response $response) : Response
$this->sitemap = $sitemap;

// Run event onSitemapAfterInitialized
$this->flextype->container('emitter')->emit('onSitemapAfterInitialized');
flextype('emitter')->emit('onSitemapAfterInitialized');

// Set response header
$response = $response->withHeader('Content-Type', 'application/xml');

return $this->flextype->container('twig')->render(
return flextype('twig')->render(
$response,
'plugins/sitemap/templates/index.html',
[
Expand Down
4 changes: 2 additions & 2 deletions dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

use Flextype\Plugin\Sitemap\Controllers\SitemapController;

$flextype->container()['SitemapController'] = function () use ($flextype) {
return new SitemapController($flextype);
flextype()->container()['SitemapController'] = function () {
return new SitemapController();
};
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Sitemap
version: 2.3.0
version: 2.4.0
description: Provide automatically generated XML sitemap.
author:
name: Sergey Romanenko
Expand All @@ -14,5 +14,5 @@ keywords: sitemap, plugin, xml, map, index
license: MIT

dependencies:
flextype: 0.9.10
flextype: 0.9.11
twig: '>=1.0.0'
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace Flextype;

$flextype->get('/' . $flextype->container('registry')->get('plugins.sitemap.settings.route'), 'SitemapController:index')->setName('sitemap.index');
flextype()->get('/' . flextype('registry')->get('plugins.sitemap.settings.route'), 'SitemapController:index')->setName('sitemap.index');

0 comments on commit 23abe5d

Please sign in to comment.