diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index af717269..0e962caa 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
- php: ['7.3', '7.4', '8.0']
+ php: ['7.4', '8.0']
dependency-version: [prefer-stable]
steps:
diff --git a/.htaccess b/.htaccess
index 85c9057e..300e581a 100755
--- a/.htaccess
+++ b/.htaccess
@@ -1,5 +1,5 @@
##
-# Flextype (http://flextype.org)
+# Flextype (https://flextype.org)
# Founded by Sergey Romanenko and maintained by Flextype Community.
#
diff --git a/BACKERS.md b/BACKERS.md
index 41de6a76..6f302220 100644
--- a/BACKERS.md
+++ b/BACKERS.md
@@ -5,7 +5,7 @@ Flextype is an MIT-licensed open source project and completely free to use..
However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing. You can support it's ongoing development by being a backer or a sponsor:
* [Become a backer or sponsor on Patreon](https://www.patreon.com/awilum).
-* [One-time donation via PayPal, QIWI, Sberbank, Yandex](http://flextype.org/en/one-time-donation)
+* [One-time donation via PayPal, QIWI, Sberbank, Yandex](https://flextype.org/en/one-time-donation)
* [Visit our Sponsors & Backers page](https://flextype.org/en/sponsors)
### Gold Sponsor
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bed5200c..76f28102 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,24 @@
+
+# [0.9.14](https://github.com/flextype/flextype/compare/v0.9.13...v0.9.14) (2020-12-30)
+
+### Features
+
+* **core** Moving to PHP 7.4.0 ([#524](https://github.com/flextype/flextype/issues/524))
+
+* **plugins** Set default plugin priority 100 and SORT them ascending ([#523](https://github.com/flextype/flextype/issues/523))
+
+### Bug Fixes
+
+* **core** fix issue with Rest API endpoints detection. ([#522](https://github.com/flextype/flextype/issues/522))
+
+* **entries** fix issue with empty variable $data in fetch() method. ([#531](https://github.com/flextype/flextype/issues/531))
+
+* **entries** fix issue with deleteStorage() method return data.
+
+### Refactoring
+
+* **core** general code refactoring and improvements.
+
# [0.9.13](https://github.com/flextype/flextype/compare/v0.9.12...v0.9.13) (2020-12-20)
diff --git a/README.md b/README.md
index bb57085e..c8dc1892 100755
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ The underlying architecture of Flextype is built using well established and best
Make sure your server meets the following requirements.
* Webserver (Apache with Mod Rewrite)
-* PHP 7.3.0 or higher
+* PHP 7.4.0 or higher
#### PHP EXTENSIONS
Flextype needs the following PHP extensions to be enabled:
diff --git a/composer.json b/composer.json
index 499c220e..8d9dc155 100755
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
"issues": "https://github.com/flextype/flextype/issues"
},
"require": {
- "php": "^7.3 || ^8.0",
+ "php": "^7.4 || ^8.0",
"ext-json": "*",
"ext-dom": "*",
"ext-spl": "*",
diff --git a/index.php b/index.php
index 14b9a206..8929535d 100755
--- a/index.php
+++ b/index.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.
*/
@@ -21,7 +21,7 @@ use const PHP_VERSION;
/**
* Define the application minimum supported PHP version.
*/
-define('FLEXTYPE_MINIMUM_PHP', '7.3.0');
+define('FLEXTYPE_MINIMUM_PHP', '7.4.0');
/**
* Define the PATH to the root directory (without trailing slash).
@@ -32,8 +32,8 @@ define('ROOT_DIR', str_replace(DIRECTORY_SEPARATOR, '/', getcwd()));
* Define the PATH (without trailing slash).
*/
define('PATH', [
- 'project' => ROOT_DIR . '/project',
- 'tmp' => ROOT_DIR . '/var/tmp',
+ 'project' => ROOT_DIR . '/project',
+ 'tmp' => ROOT_DIR . '/var/tmp',
]);
/**
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 00000000..aa8255cc
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,10 @@
+parameters:
+ level: 0
+ reportUnmatchedIgnoredErrors: false
+ paths:
+ - src
+ ignoreErrors:
+ - '/Constant PATH not found./'
+ - '/Constant ROOT_DIR not found./'
+ - '/Variable \$api_errors might not be defined./'
+ - '/Variable \$registry might not be defined./'
diff --git a/src/flextype/Endpoints/Utils/access.php b/src/flextype/Endpoints/Utils/access.php
index 614c9434..c47c1187 100644
--- a/src/flextype/Endpoints/Utils/access.php
+++ b/src/flextype/Endpoints/Utils/access.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.
*/
@@ -14,7 +14,7 @@ use function filesystem;
/**
* Validate access token
*/
-function validate_access_token($token): bool
+function validate_access_token(string $token): bool
{
return filesystem()->file(PATH['project'] . '/tokens/access/' . $token . '/token.yaml')->exists();
}
diff --git a/src/flextype/Endpoints/Utils/errors.php b/src/flextype/Endpoints/Utils/errors.php
index ec78f3fc..43926445 100644
--- a/src/flextype/Endpoints/Utils/errors.php
+++ b/src/flextype/Endpoints/Utils/errors.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.
*/
diff --git a/src/flextype/Endpoints/entries.php b/src/flextype/Endpoints/entries.php
index b9812a39..ddcc1579 100644
--- a/src/flextype/Endpoints/entries.php
+++ b/src/flextype/Endpoints/entries.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.
*/
@@ -22,7 +22,7 @@ use function is_array;
/**
* Validate entries entries token
*/
-function validate_entries_token($token): bool
+function validate_entries_token(string $token): bool
{
return filesystem()->file(PATH['project'] . '/tokens/entries/' . $token . '/token.yaml')->exists();
}
@@ -143,7 +143,7 @@ flextype()->get('/api/entries', function (Request $request, Response $response)
*/
flextype()->post('/api/entries', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['data'])) {
return $response
@@ -253,7 +253,7 @@ flextype()->post('/api/entries', function (Request $request, Response $response)
*/
flextype()->patch('/api/entries', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['data'])) {
return $response
@@ -363,7 +363,7 @@ flextype()->patch('/api/entries', function (Request $request, Response $response
*/
flextype()->put('/api/entries', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['new_id'])) {
return $response
@@ -474,7 +474,7 @@ flextype()->put('/api/entries', function (Request $request, Response $response)
*/
flextype()->put('/api/entries/copy', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['new_id'])) {
return $response
@@ -584,7 +584,7 @@ flextype()->put('/api/entries/copy', function (Request $request, Response $respo
*/
flextype()->delete('/api/entries', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id'])) {
return $response
diff --git a/src/flextype/Endpoints/images.php b/src/flextype/Endpoints/images.php
index c9d32958..2e671de9 100644
--- a/src/flextype/Endpoints/images.php
+++ b/src/flextype/Endpoints/images.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.
*/
@@ -19,7 +19,7 @@ use function flextype;
/**
* Validate images token
*/
-function validate_images_token($token): bool
+function validate_images_token(string $token): bool
{
return filesystem()->file(PATH['project'] . '/tokens/images/' . $token . '/token.yaml')->exists();
}
diff --git a/src/flextype/Endpoints/media.php b/src/flextype/Endpoints/media.php
index d9baa30e..ca1a4f12 100644
--- a/src/flextype/Endpoints/media.php
+++ b/src/flextype/Endpoints/media.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.
*/
@@ -23,7 +23,7 @@ use function is_dir;
/**
* Validate files token
*/
-function validate_files_token($token): bool
+function validate_files_token(string $token): bool
{
return filesystem()->file(PATH['project'] . '/tokens/media/files/' . $token . '/token.yaml')->exists();
}
@@ -31,7 +31,7 @@ function validate_files_token($token): bool
/**
* Validate folders token
*/
-function validate_folders_token($token): bool
+function validate_folders_token(string $token): bool
{
return filesystem()->file(PATH['project'] . '/tokens/media/folders/' . $token . '/token.yaml')->exists();
}
@@ -155,7 +155,7 @@ flextype()->get('/api/media/files', function (Request $request, Response $respon
*/
flextype()->post('/api/media/files', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['folder']) || ! isset($_FILES['file'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -265,7 +265,7 @@ flextype()->post('/api/media/files', function (Request $request, Response $respo
*/
flextype()->put('/api/media/files', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['new_id'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -374,7 +374,7 @@ flextype()->put('/api/media/files', function (Request $request, Response $respon
*/
flextype()->put('/api/media/files/copy', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['new_id'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -482,7 +482,7 @@ flextype()->put('/api/media/files/copy', function (Request $request, Response $r
*/
flextype()->delete('/api/media/files', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['id']) || ! isset($post_data['access_token']) || ! isset($post_data['id'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -533,7 +533,7 @@ flextype()->delete('/api/media/files', function (Request $request, Response $res
$response_code = $delete_file ? 204 : 404;
// Update calls counter
- filesystem()->file($files_token_file_path)->get(flextype('serializers')->yaml()->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
+ filesystem()->file($files_token_file_path)->put(flextype('serializers')->yaml()->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
if ($response_code === 404) {
// Return response
@@ -585,7 +585,7 @@ flextype()->delete('/api/media/files', function (Request $request, Response $res
*/
flextype()->patch('/api/media/files/meta', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['field']) || ! isset($post_data['value'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -609,7 +609,7 @@ flextype()->patch('/api/media/files/meta', function (Request $request, Response
// Set files and access token file
if (
($files_token_file_data = flextype('serializers')->yaml()->decode(filesystem()->file($files_token_file_path)->get())) &&
- ($access_token_file_data = flextype('serializers')->yaml()->decode(filesystem()->file($access_token_file_path)->get($access_token_file_path)))
+ ($access_token_file_data = flextype('serializers')->yaml()->decode(filesystem()->file($access_token_file_path)->get()))
) {
if (
$files_token_file_data['state'] === 'disabled' ||
@@ -696,7 +696,7 @@ flextype()->patch('/api/media/files/meta', function (Request $request, Response
*/
flextype()->post('/api/media/files/meta', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['field']) || ! isset($post_data['value'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -807,7 +807,7 @@ flextype()->post('/api/media/files/meta', function (Request $request, Response $
*/
flextype()->delete('/api/media/files/meta', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['field'])) {
return $response->withStatus($api_errors['0501']['http_status_code'])
@@ -1020,7 +1020,7 @@ flextype()->get('/api/media/folders', function (Request $request, Response $resp
*/
flextype()->post('/api/media/folders', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id'])) {
return $response->withStatus($api_errors['0601']['http_status_code'])
@@ -1126,7 +1126,7 @@ flextype()->post('/api/media/folders', function (Request $request, Response $res
*/
flextype()->put('/api/media/folders/copy', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['new_id'])) {
return $response->withStatus($api_errors['0601']['http_status_code'])
@@ -1235,7 +1235,7 @@ flextype()->put('/api/media/folders/copy', function (Request $request, Response
*/
flextype()->put('/api/media/folders', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id']) || ! isset($post_data['new_id'])) {
return $response->withStatus($api_errors['0601']['http_status_code'])
@@ -1341,7 +1341,7 @@ flextype()->put('/api/media/folders', function (Request $request, Response $resp
*/
flextype()->delete('/api/media/folders', function (Request $request, Response $response) use ($api_errors) {
// Get Post Data
- $post_data = $request->getParsedBody();
+ $post_data = (array) $request->getParsedBody();
if (! isset($post_data['token']) || ! isset($post_data['access_token']) || ! isset($post_data['id'])) {
return $response->withStatus($api_errors['0601']['http_status_code'])
diff --git a/src/flextype/Endpoints/registry.php b/src/flextype/Endpoints/registry.php
index 273de334..87d0fcdd 100644
--- a/src/flextype/Endpoints/registry.php
+++ b/src/flextype/Endpoints/registry.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.
*/
@@ -19,7 +19,7 @@ use function flextype;
/**
* Validate registry token
*/
-function validate_registry_token($token): bool
+function validate_registry_token(string $token): bool
{
return filesystem()->file(PATH['project'] . '/tokens/registry/' . $token . '/token.yaml')->exists();
}
diff --git a/src/flextype/Foundation/Entries/Entries.php b/src/flextype/Foundation/Entries/Entries.php
index 3c38eb41..53befecf 100755
--- a/src/flextype/Foundation/Entries/Entries.php
+++ b/src/flextype/Foundation/Entries/Entries.php
@@ -33,7 +33,7 @@ class Entries
* @var array
* @access private
*/
- private $storage = [
+ private array $storage = [
'fetch' => [
'id' => '',
'data' => [],
@@ -74,7 +74,7 @@ class Entries
*
* @access public
*
- * @return self Returns instance of The Arrays class.
+ * @return Arrays Returns instance of The Arrays class with items.
*/
public function fetch(string $id, array $options = []): Arrays
{
@@ -179,6 +179,9 @@ class Entries
// Walk through entries results
if ($entries->hasResults()) {
+
+ $data = [];
+
foreach ($entries as $currenEntry) {
if ($currenEntry->getType() !== 'file' || $currenEntry->getFilename() !== 'entry' . '.' . flextype('registry')->get('flextype.settings.entries.extension')) {
continue;
@@ -415,11 +418,13 @@ class Entries
*
* @access public
*
- * @return array Updated storage.
+ * @return self Returns instance of The Entries class.
*/
- public function setStorage(?string $key, $value): void
+ public function setStorage(?string $key, $value): self
{
$this->storage = arrays($this->storage)->set($key, $value)->toArray();
+
+ return $this;
}
/**
@@ -427,11 +432,13 @@ class Entries
*
* @param array|string $keys Keys
*
- * @return array Updated storage.
+ * @return self Returns instance of The Entries class.
*/
public function deleteStorage($keys): self
{
- return $this->storage = arrays($this->storage)->delete($keys)->toArray();
+ $this->storage = arrays($this->storage)->delete($keys)->toArray();
+
+ return $this;
}
/**
diff --git a/src/flextype/Foundation/Entries/Fields/EntriesField.php b/src/flextype/Foundation/Entries/Fields/EntriesField.php
index 2a05e0a4..c3ee7208 100644
--- a/src/flextype/Foundation/Entries/Fields/EntriesField.php
+++ b/src/flextype/Foundation/Entries/Fields/EntriesField.php
@@ -14,6 +14,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.entries.fetch.en
if (flextype('entries')->hasStorage('fetch.data.entries.fetch')) {
// Get fetch.
$original = flextype('entries')->getStorage('fetch');
+ $data = [];
switch (flextype('registry')->get('flextype.settings.entries.fields.entries.fetch.result')) {
case 'toArray':
diff --git a/src/flextype/Foundation/Entries/Fields/MediaField.php b/src/flextype/Foundation/Entries/Fields/MediaField.php
index eb4823ed..c0f31fb9 100644
--- a/src/flextype/Foundation/Entries/Fields/MediaField.php
+++ b/src/flextype/Foundation/Entries/Fields/MediaField.php
@@ -14,6 +14,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.media.files.fetc
if (flextype('entries')->hasStorage('fetch.data.media.files.fetch')) {
// Get fetch.
$original = flextype('entries')->getStorage('fetch');
+ $data = [];
switch (flextype('registry')->get('flextype.settings.entries.fields.media.files.fetch.result')) {
case 'toArray':
@@ -63,6 +64,7 @@ if (flextype('registry')->get('flextype.settings.entries.fields.media.folders.fe
// Get fetch.
$original = flextype('entries')->getStorage('fetch');
+ $data = [];
switch (flextype('registry')->get('flextype.settings.entries.fields.media.folders.fetch.result')) {
case 'toArray':
diff --git a/src/flextype/Foundation/Flextype.php b/src/flextype/Foundation/Flextype.php
index 8afd92c8..e1a75185 100644
--- a/src/flextype/Foundation/Flextype.php
+++ b/src/flextype/Foundation/Flextype.php
@@ -22,7 +22,7 @@ final class Flextype extends App
/**
* Flextype version
*/
- public const VERSION = '0.9.13';
+ public const VERSION = '0.9.14';
/**
* The Flextype's instance is stored in a static field. This field is an
@@ -31,7 +31,7 @@ final class Flextype extends App
*
* @var array
*/
- private static $instances = [];
+ private static array $instances = [];
/**
* Flextype should not be cloneable.
@@ -88,16 +88,6 @@ final class Flextype extends App
return self::$instances[$cls];
}
- /**
- * Determine API Request
- *
- * @return bool
- */
- public function isApiRequest(): bool
- {
- return explode('/', Uri::createFromEnvironment(new Environment($_SERVER))->getPath())[0] === 'api';
- }
-
/**
* Returns the current Flextype version
*/
diff --git a/src/flextype/Foundation/Helpers/FlextypeHelper.php b/src/flextype/Foundation/Helpers/FlextypeHelper.php
index fd690438..a181b567 100644
--- a/src/flextype/Foundation/Helpers/FlextypeHelper.php
+++ b/src/flextype/Foundation/Helpers/FlextypeHelper.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.
*/
diff --git a/src/flextype/Foundation/Plugins.php b/src/flextype/Foundation/Plugins.php
index 15544ad0..5c254686 100755
--- a/src/flextype/Foundation/Plugins.php
+++ b/src/flextype/Foundation/Plugins.php
@@ -34,7 +34,7 @@ class Plugins
*
* @var array
*/
- private $locales = [];
+ private array $locales = [];
/**
* Constructor
@@ -95,13 +95,14 @@ class Plugins
}
} else {
// Init plugin configs
- $plugins = [];
+ $plugins = [];
$defaultPluginSettings = [];
$projectPluginSettings = [];
$defaultPluginManifest = [];
// Go through...
foreach ($pluginsList as $plugin) {
+
// Set plugin settings directory
$projectPluginSettingsDir = PATH['project'] . '/config/plugins/' . $plugin['dirname'];
@@ -121,7 +122,7 @@ class Plugins
}
// Get default plugin settings content
- $defaultPluginSettingsFileContent = filesystem()->file($defaultPluginSettingsFile)->get();
+ $defaultPluginSettingsFileContent = filesystem()->file($defaultPluginSettingsFile)->get();
$defaultPluginSettings = flextype('serializers')->yaml()->decode($defaultPluginSettingsFileContent);
// Create project plugin settings file
@@ -142,7 +143,7 @@ class Plugins
}
// Get default plugin manifest content
- $defaultPluginManifestFileContent = filesystem()->file($defaultPluginManifestFile)->get();
+ $defaultPluginManifestFileContent = filesystem()->file($defaultPluginManifestFile)->get();
$defaultPluginManifest = flextype('serializers')->yaml()->decode($defaultPluginManifestFileContent);
// Merge plugin settings and manifest data
@@ -160,7 +161,7 @@ class Plugins
}
// Sort plugins list by priority.
- $plugins = arrays($plugins)->sortBy('_priority', 'DESC')->toArray();
+ $plugins = arrays($plugins)->sortBy('_priority', 'ASC')->toArray();
// ... and delete tmp _priority field for sorting
foreach ($plugins as $pluginName => $pluginData) {
@@ -378,7 +379,7 @@ class Plugins
continue;
}
- include_once PATH['project'] . '/plugins/' . $pluginName . '/bootstrap.php';
+ include_once PATH['project'] . '/plugins/' . $pluginName . '/plugin.php';
}
}
}
diff --git a/src/flextype/Support/Helpers/FilterHelper.php b/src/flextype/Support/Helpers/FilterHelper.php
index 5f318719..08415fa9 100644
--- a/src/flextype/Support/Helpers/FilterHelper.php
+++ b/src/flextype/Support/Helpers/FilterHelper.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.
*/
diff --git a/src/flextype/Support/Helpers/FindHelper.php b/src/flextype/Support/Helpers/FindHelper.php
index 52d293d1..e401c75c 100644
--- a/src/flextype/Support/Helpers/FindHelper.php
+++ b/src/flextype/Support/Helpers/FindHelper.php
@@ -3,11 +3,11 @@
declare(strict_types=1);
/**
- * Flextype (http://flextype.org)
+ * Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
-use Symfony\Component\Finder\Finder;
+use Symfony\Component\Finder\Finder as Finder;
if (! function_exists('find')) {
/**
@@ -17,7 +17,7 @@ if (! function_exists('find')) {
* @param array $options Options array.
* @param string $searchIn Search in 'files' or 'directories'. Default is 'files'.
*
- * @return Symfony\Component\Finder
+ * @return Finder
*/
function find(string $path = '', array $options = [], string $searchIn = 'files'): Finder
{
diff --git a/src/flextype/Support/Parsers/Shortcode.php b/src/flextype/Support/Parsers/Shortcode.php
index 09517770..5dc17046 100644
--- a/src/flextype/Support/Parsers/Shortcode.php
+++ b/src/flextype/Support/Parsers/Shortcode.php
@@ -49,8 +49,6 @@ final class Shortcode
/**
* Shortcode construct
- *
- * @param
*/
protected function __construct()
{
@@ -59,8 +57,6 @@ final class Shortcode
/**
* Shortcode facade
- *
- * @param
*/
public function facade(): ShortcodeFacade
{
@@ -69,8 +65,6 @@ final class Shortcode
/**
* Returns Shortcode Instance
- *
- * @param
*/
public static function getInstance(): Shortcode
{
diff --git a/src/flextype/bootstrap.php b/src/flextype/bootstrap.php
index e679d8cf..0116082c 100755
--- a/src/flextype/bootstrap.php
+++ b/src/flextype/bootstrap.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.
*/
@@ -57,7 +57,6 @@ $flextype = Flextype::getInstance([
],
]);
-
/**
* Display Errors
*/
@@ -172,14 +171,12 @@ flextype('plugins')->init();
/**
* Include API ENDPOINTS
*/
-if (flextype()->isApiRequest()) {
- include_once ROOT_DIR . '/src/flextype/Endpoints/Utils/errors.php';
- include_once ROOT_DIR . '/src/flextype/Endpoints/Utils/access.php';
- include_once ROOT_DIR . '/src/flextype/Endpoints/entries.php';
- include_once ROOT_DIR . '/src/flextype/Endpoints/registry.php';
- include_once ROOT_DIR . '/src/flextype/Endpoints/media.php';
- include_once ROOT_DIR . '/src/flextype/Endpoints/images.php';
-}
+include_once ROOT_DIR . '/src/flextype/Endpoints/Utils/errors.php';
+include_once ROOT_DIR . '/src/flextype/Endpoints/Utils/access.php';
+include_once ROOT_DIR . '/src/flextype/Endpoints/entries.php';
+include_once ROOT_DIR . '/src/flextype/Endpoints/registry.php';
+include_once ROOT_DIR . '/src/flextype/Endpoints/media.php';
+include_once ROOT_DIR . '/src/flextype/Endpoints/images.php';
/**
* Enable lazy CORS
@@ -190,6 +187,11 @@ if (flextype()->isApiRequest()) {
*/
flextype('cors')->init();
+/**
+ * Run high priority event: onFlextypeBeforeRun before Flextype Application starts.
+ */
+flextype('emitter')->emit('onFlextypeBeforeRun');
+
/**
* Run application
*/
diff --git a/src/flextype/dependencies.php b/src/flextype/dependencies.php
index 177c753f..25980428 100644
--- a/src/flextype/dependencies.php
+++ b/src/flextype/dependencies.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.
*/
@@ -54,23 +54,17 @@ use function sys_get_temp_dir;
/**
* Create a standard session hanndler
*/
-flextype()->container()['session'] = static function () {
- return new Session();
-};
+flextype()->container()['session'] = fn() => new Session();
/**
* Supply a custom callable resolver, which resolves PSR-15 middlewares.
*/
-flextype()->container()['callableResolver'] = static function () {
- return new CallableResolver(flextype()->container());
-};
+flextype()->container()['callableResolver'] = fn() => new CallableResolver(flextype()->container());
/**
* Add registry service to Flextype container
*/
-flextype()->container()['registry'] = static function () use ($registry) {
- return $registry;
-};
+flextype()->container()['registry'] = $registry;
/**
* Add logger service to Flextype container
@@ -85,9 +79,7 @@ flextype()->container()['logger'] = static function () {
/**
* Add emitter service to Flextype container
*/
-flextype()->container()['emitter'] = static function () {
- return new Emitter();
-};
+flextype()->container()['emitter'] = fn() => new Emitter();
/**
* Add slugify service to Flextype container
@@ -216,16 +208,12 @@ flextype()->container()['cache'] = static function () {
/**
* Add parsers service to Flextype container
*/
-flextype()->container()['parsers'] = static function () {
- return new Parsers();
-};
+flextype()->container()['parsers'] = fn() => new Parsers();
/**
* Add serializer service to Flextype container
*/
-flextype()->container()['serializers'] = static function () {
- return new Serializers();
-};
+flextype()->container()['serializers'] = fn() => new Serializers();
/**
* Add images service to Flextype container
@@ -285,27 +273,19 @@ flextype()->container()['images'] = static function () {
/**
* Add entries service to Flextype container
*/
-flextype()->container()['entries'] = static function () {
- return new Entries();
-};
+flextype()->container()['entries'] = fn() => new Entries();
/**
* Add media service to Flextype container
*/
-flextype()->container()['media'] = static function () {
- return new Media();
-};
+flextype()->container()['media'] = fn() => new Media();
/**
* Add plugins service to Flextype container
*/
-flextype()->container()['plugins'] = static function () {
- return new Plugins();
-};
+flextype()->container()['plugins'] = fn() => new Plugins();
/**
* Add cors service to Flextype container
*/
-flextype()->container()['cors'] = static function () {
- return new Cors();
-};
+flextype()->container()['cors'] = fn() => new Cors();
diff --git a/src/flextype/flextype.yaml b/src/flextype/flextype.yaml
index 31ec3d10..e5fcc2b8 100644
--- a/src/flextype/flextype.yaml
+++ b/src/flextype/flextype.yaml
@@ -1,5 +1,5 @@
name: Flextype
-version: 0.9.13
+version: 0.9.14
description: Hybrid Content Management System
author:
name: Sergey Romanenko
diff --git a/src/flextype/preflight.php b/src/flextype/preflight.php
index bb2bf389..a722e900 100644
--- a/src/flextype/preflight.php
+++ b/src/flextype/preflight.php
@@ -8,7 +8,7 @@ $flextypeManifestFilePath = ROOT_DIR . '/src/flextype/flextype.yaml';
$defaultFlextypeSettingsFilePath = ROOT_DIR . '/src/flextype/settings.yaml';
$customFlextypeSettingsFilePath = PATH['project'] . '/config/flextype/settings.yaml';
$preflightFlextypePath = PATH['tmp'] . '/preflight/flextype/';
-$customFlextypeSettingsPath = PATH['project'] . '/config/flextype/';
+$customFlextypeSettingsPath = PATH['project'] . '/config/flextype/';
! filesystem()->directory($preflightFlextypePath)->exists() and filesystem()->directory($preflightFlextypePath)->create(0755, true);
! filesystem()->directory($customFlextypeSettingsPath)->exists() and filesystem()->directory($customFlextypeSettingsPath)->create(0755, true);