diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eabc25..29e658e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ + +# [1.8.0](https://github.com/flextype-plugins/site/compare/v1.7.0...v1.8.0) (2020-12-30) + +### Features + +* **core** update code base for new Flextype 0.9.14 +* **core** Moving to PHP 7.4 +* **core** use new TWIG Plugin 1.7.0 +* **routes** use new `onFlextypeBeforeRun` event for site routing. + +BREAKING CHANGES + +* removed `$entry` property, use entries storage functionality instead. +* removed even `onSiteEntryAfterInitialized`, use event `onEntriesFetchSingleHasResult` instead. +* removed template variable `query` and `uri`, use an full power of new `$request` variable. + # [1.7.0](https://github.com/flextype-plugins/site/compare/v1.6.1...v1.7.0) (2020-12-23) diff --git a/README.md b/README.md index 0202e09..d4a2783 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -

Site Plugin for Flextype

+

Site Plugin for Flextype

-Version License Total downloads Flextype Discord +Version License Total downloads Flextype Discord

Site plugin to display entries content on the website frontend. @@ -14,7 +14,7 @@ The following dependencies need to be downloaded and installed for Site Plugin. | Item | Version | Download | |---|---|---| -| [flextype](https://github.com/flextype/flextype) | 0.9.13 | [download](https://github.com/flextype/flextype/releases) | +| [flextype](https://github.com/flextype/flextype) | 0.9.14 | [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) | | [noir](https://github.com/flextype-themes/noir) | >=1.0.0 | [download](https://github.com/flextype-themes/noir/releases) | @@ -76,8 +76,8 @@ You can reach any of these items via registry `themes` by using the standard dot Usage: ```twig -Theme name: {{ registry.get('themes.noir.manifest.name') }} -Theme version: {{ registry.get('themes.noir.manifest.version') }} +Theme name: {{ flextype.registry.get('themes.noir.manifest.name') }} +Theme version: {{ flextype.registry.get('themes.noir.manifest.version') }} ``` Result: @@ -118,7 +118,7 @@ highlight: red Then in your theme templates you can access these variable using the `themes.noir` object: ```twig -

+

BUILD FAST, FLEXIBLE, EASIER TO MANAGE WEBSITES WITH FLEXTYPE.

``` diff --git a/app/Controllers/SiteController.php b/app/Controllers/SiteController.php index aa7137d..79cc10b 100644 --- a/app/Controllers/SiteController.php +++ b/app/Controllers/SiteController.php @@ -20,14 +20,6 @@ class SiteController { - /** - * Current entry data array - * - * @var array - * @access private - */ - public $entry = []; - /** * Index page * @@ -70,36 +62,28 @@ public function index(Request $request, Response $response, array $args) : Respo $entry = $entry_body; } } else { - $entry = $this->error404(); + $entry = $this->error404(); $isEntryNotFound = true; } - // Set entry - $this->entry = $entry; - - // Run event onSiteEntryAfterInitialized - flextype('emitter')->emit('onSiteEntryAfterInitialized'); - // Return in JSON Format if ($isJson) { if ($isEntryNotFound) { - return $response->withJson($this->entry, 404); + return $response->withJson($entry, 404); } - return $response->withJson($this->entry); + return $response->withJson($entry); } // Set template path for current entry - $path = 'themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/' . (empty($this->entry['template']) ? 'templates/default' : 'templates/' . $this->entry['template']) . '.html'; + $path = 'themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/' . (empty($entry['template']) ? 'templates/default' : 'templates/' . $entry['template']) . '.html'; if (! Filesystem::has(PATH['project'] . '/' . $path)) { - return $response->write("Template {$this->entry['template']} not found"); + return $response->write("Template {$entry['template']} not found"); } - $data = ['entry' => $this->entry, - 'query' => $query, - 'uri' => $uri, - 'args' => $args, + $data = ['entry' => $entry, + 'args' => $args, 'request' => $request]; if ($isEntryNotFound) { diff --git a/app/Models/Themes.php b/app/Models/Themes.php index ddc6320..b9e4696 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * Flextype (http://flextype.org) + * Flextype (https://flextype.org) * Founded by Sergey Romanenko and maintained by Flextype Community. */ @@ -20,16 +20,6 @@ class Themes { - /** - * Private construct method to enforce singleton behavior. - * - * @access private - */ - public function __construct() - { - - } - /** * Init themes */ diff --git a/composer.json b/composer.json index 288ded8..c545bf3 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "issues": "https://github.com/flextype-plugins/site/issues" }, "require": { - "php": ">=7.3.0", + "php": ">=7.4.0", "ext-json": "*", "middlewares/trailing-slash": "~1.1.0", "flextype-components/arrays" : "3.0.1", @@ -26,7 +26,7 @@ "apcu-autoloader": true, "optimize-autoloader": true, "platform": { - "php": "7.3.0" + "php": "7.4.0" } }, "autoload": { diff --git a/dependencies.php b/dependencies.php index 890e142..5ea153e 100644 --- a/dependencies.php +++ b/dependencies.php @@ -17,9 +17,7 @@ /** * Add themes service to Flextype container */ -flextype()->container()['themes'] = static function () { - return new Themes(); -}; +flextype()->container()['themes'] = fn() => new Themes(); /** * Init themes @@ -29,9 +27,7 @@ /** * Add site controller to Flextype container */ -flextype()->container()['SiteController'] = static function () { - return new SiteController(); -}; +flextype()->container()['SiteController'] = fn() => new SiteController(); -$bootstrapPath = PATH['project']. '/themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/bootstrap.php'; -filesystem()->file($bootstrapPath)->exists() and include_once $bootstrapPath; +$themeBootstrapPath = PATH['project']. '/themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/theme.php'; +filesystem()->file($themeBootstrapPath)->exists() and include_once $themeBootstrapPath; diff --git a/lang/en_US.yaml b/lang/en_US.yaml index 58e2777..d5def15 100755 --- a/lang/en_US.yaml +++ b/lang/en_US.yaml @@ -1,3 +1,3 @@ site_title: Site site_description: Site plugin to display entries content on the website frontend. -site_powered_by_flextype: Build fast, flexible, easier to manage websites with Flextype. +site_powered_by_flextype: Build fast, flexible, easier to manage websites with Flextype. diff --git a/lang/ru_RU.yaml b/lang/ru_RU.yaml index 4be5950..1e80b06 100755 --- a/lang/ru_RU.yaml +++ b/lang/ru_RU.yaml @@ -1,3 +1,3 @@ site_title: Site site_description: Site plugin to display entries content on the website frontend. -site_powered_by_flextype: Создавайте быстрые и легкие в управлении веб-сайты c Flextype. +site_powered_by_flextype: Создавайте быстрые и легкие в управлении веб-сайты c Flextype. diff --git a/plugin.yaml b/plugin.yaml index 5f52ce3..8e3f33d 100755 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: Site -version: 1.7.0 +version: 1.8.0 description: Site plugin to display entries content on the website frontend. icon: fas fa-globe author: @@ -11,5 +11,5 @@ bugs: https://github.com/flextype-plugins/site/issues license: MIT dependencies: - flextype: 0.9.13 + flextype: 0.9.14 twig: '>=1.0.0' diff --git a/routes/web.php b/routes/web.php index 486d1de..1024126 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,6 +12,7 @@ use Slim\Http\Environment; use Slim\Http\Uri; -if (! flextype()->isApiRequest()) { + +flextype('emitter')->addListener('onFlextypeBeforeRun', static function (): void { flextype()->get('{uri:.+}', 'SiteController:index')->setName('site.index')->add('csrf'); -} +}); diff --git a/settings.yaml b/settings.yaml index 36ff12a..305959b 100644 --- a/settings.yaml +++ b/settings.yaml @@ -2,7 +2,7 @@ enabled: true # Site plugin priority -priority: 0 +priority: 10000 # The title of the website title: Flextype