mirror of
https://github.com/flextype/flextype.git
synced 2025-08-11 23:54:06 +02:00
refactor(core): code formating and refactoring
This commit is contained in:
@@ -105,7 +105,6 @@ class Entries
|
||||
|
||||
// 2. Try to get current requested entry from filesystem
|
||||
if ($this->has($this->storage['fetch']['id'])) {
|
||||
|
||||
// Get entry file location
|
||||
$entryFile = $this->getFileLocation($this->storage['fetch']['id']);
|
||||
|
||||
|
@@ -7,7 +7,6 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.id.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
|
||||
|
@@ -15,38 +15,59 @@ if (flextype('registry')->get('flextype.settings.entries.fields.parsers.enabled'
|
||||
|
||||
function processParsersField(): void
|
||||
{
|
||||
if (flextype('entries')->getStorage('fetch.data.cache.enabled') == null) {
|
||||
if (flextype('entries')->getStorage('fetch.data.cache.enabled') === null) {
|
||||
$cache = false;
|
||||
} else {
|
||||
$cache = (bool) flextype('entries')->getStorage('fetch.data.cache.enabled');
|
||||
}
|
||||
|
||||
if (flextype('entries')->getStorage('fetch.data.parsers') != null) {
|
||||
foreach (flextype('entries')->getStorage('fetch.data.parsers') as $parser_name => $parser_data) {
|
||||
if (in_array($parser_name, ['markdown', 'shortcode'])) {
|
||||
if (flextype('entries')->getStorage('fetch.data.parsers.'.$parser_name.'.enabled') === true) {
|
||||
if (flextype('entries')->getStorage('fetch.data.parsers.'.$parser_name.'.fields') != null) {
|
||||
if (is_array(flextype('entries')->getStorage('fetch.data.parsers.'.$parser_name.'.fields'))) {
|
||||
foreach (flextype('entries')->getStorage('fetch.data.parsers.'.$parser_name.'.fields') as $field) {
|
||||
if (! in_array($field, flextype('registry')->get('flextype.settings.entries.fields'))) {
|
||||
if ($parser_name == 'markdown') {
|
||||
if (arrays(flextype('entries')->getStorage('fetch.data'))->has($field)) {
|
||||
flextype('entries')->setStorage('fetch.data.'.$field,
|
||||
flextype('markdown')->parse(flextype('entries')->getStorage('fetch.data.'.$field), $cache));
|
||||
}
|
||||
}
|
||||
if ($parser_name == 'shortcode') {
|
||||
if (arrays(flextype('entries')->getStorage('fetch.data'))->has($field)) {
|
||||
flextype('entries')->setStorage('fetch.data.'.$field,
|
||||
flextype('shortcode')->process(flextype('entries')->getStorage('fetch.data.'.$field), $cache));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flextype('entries')->getStorage('fetch.data.parsers') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (flextype('entries')->getStorage('fetch.data.parsers') as $parser_name => $parser_data) {
|
||||
if (! in_array($parser_name, ['markdown', 'shortcode'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flextype('entries')->getStorage('fetch.data.parsers.' . $parser_name . '.enabled') !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flextype('entries')->getStorage('fetch.data.parsers.' . $parser_name . '.fields') === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_array(flextype('entries')->getStorage('fetch.data.parsers.' . $parser_name . '.fields'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (flextype('entries')->getStorage('fetch.data.parsers.' . $parser_name . '.fields') as $field) {
|
||||
if (in_array($field, flextype('registry')->get('flextype.settings.entries.fields'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($parser_name === 'markdown') {
|
||||
if (arrays(flextype('entries')->getStorage('fetch.data'))->has($field)) {
|
||||
flextype('entries')->setStorage(
|
||||
'fetch.data.' . $field,
|
||||
flextype('markdown')->parse(flextype('entries')->getStorage('fetch.data.' . $field), $cache)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($parser_name !== 'shortcode') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! arrays(flextype('entries')->getStorage('fetch.data'))->has($field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
flextype('entries')->setStorage(
|
||||
'fetch.data.' . $field,
|
||||
flextype('shortcode')->process(flextype('entries')->getStorage('fetch.data.' . $field), $cache)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.slug.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
|
||||
|
@@ -9,9 +9,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support\Parsers;
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
|
||||
use function flextype;
|
||||
use function strings;
|
||||
|
||||
class Markdown
|
||||
{
|
||||
|
@@ -9,9 +9,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support\Parsers;
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
|
||||
use function flextype;
|
||||
use function strings;
|
||||
|
||||
class Shortcode
|
||||
{
|
||||
|
@@ -9,8 +9,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support\Serializers;
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
|
||||
use function array_slice;
|
||||
use function arrays;
|
||||
use function count;
|
||||
@@ -19,6 +17,7 @@ use function implode;
|
||||
use function ltrim;
|
||||
use function preg_replace;
|
||||
use function preg_split;
|
||||
use function strings;
|
||||
|
||||
use const PHP_EOL;
|
||||
|
||||
|
@@ -9,7 +9,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support\Serializers;
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
use RuntimeException;
|
||||
|
||||
use function defined;
|
||||
@@ -18,6 +17,7 @@ use function json_decode;
|
||||
use function json_encode;
|
||||
use function json_last_error;
|
||||
use function json_last_error_msg;
|
||||
use function strings;
|
||||
|
||||
use const JSON_PRESERVE_ZERO_FRACTION;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
|
@@ -9,7 +9,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support\Serializers;
|
||||
|
||||
use Atomastic\Strings\Strings;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Yaml\Exception\DumpException as SymfonyYamlDumpException;
|
||||
use Symfony\Component\Yaml\Exception\ParseException as SymfonyYamlParseException;
|
||||
@@ -20,6 +19,7 @@ use function flextype;
|
||||
use function function_exists;
|
||||
use function ini_get;
|
||||
use function ini_set;
|
||||
use function strings;
|
||||
|
||||
class Yaml
|
||||
{
|
||||
|
@@ -10,7 +10,6 @@ declare(strict_types=1);
|
||||
namespace Flextype;
|
||||
|
||||
use Atomastic\Session\Session;
|
||||
use Atomastic\Strings\Strings;
|
||||
use Bnf\Slim3Psr15\CallableResolver;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Flextype\Foundation\Cors;
|
||||
@@ -57,6 +56,7 @@ use function date;
|
||||
use function extension_loaded;
|
||||
use function flextype;
|
||||
use function in_array;
|
||||
use function strings;
|
||||
use function sys_get_temp_dir;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user