1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(fields): updates for parsers field #199

This commit is contained in:
Awilum
2021-08-01 10:56:23 +03:00
parent 632de23a7d
commit 39fd62dd8c

View File

@@ -9,32 +9,28 @@ declare(strict_types=1);
if (registry()->get('flextype.settings.entries.fields.parsers.enabled')) {
emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void {
processParsersField();
});
}
function processParsersField(): void
{
if (entries()->registry()->get('fetch.data.cache.enabled') == null) {
$cache = false;
} else {
$cache = (bool) entries()->registry()->get('fetch.data.cache.enabled');
}
if (entries()->registry()->get('fetch.data.cache.enabled') == null) {
$cache = false;
} else {
$cache = (bool) entries()->registry()->get('fetch.data.cache.enabled');
}
if (entries()->registry()->get('fetch.data.parsers') != null) {
foreach (entries()->registry()->get('fetch.data.parsers') as $parserName => $parserData) {
if (in_array($parserName, ['shortcode'])) {
if (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.enabled') === true) {
if (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields') != null) {
if (is_array(entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields'))) {
foreach (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields') as $field) {
if (! in_array($field, registry()->get('flextype.settings.entries.fields'))) {
if ($parserName == 'shortcode') {
if (arrays(entries()->registry()->get('fetch.data'))->has($field)) {
entries()->registry()->set('fetch.data.'.$field,
parsers()->shortcode()->process(entries()->registry()->get('fetch.data.'.$field), $cache));
if (entries()->registry()->get('fetch.data.parsers') != null) {
foreach (entries()->registry()->get('fetch.data.parsers') as $parserName => $parserData) {
if (in_array($parserName, ['shortcodes'])) {
if (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.enabled') === true) {
if (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields') != null) {
if (is_array(entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields'))) {
foreach (entries()->registry()->get('fetch.data.parsers.'.$parserName.'.fields') as $field) {
if (! in_array($field, registry()->get('flextype.settings.entries.fields'))) {
if ($parserName == 'shortcodes') {
if (arrays(entries()->registry()->get('fetch.data'))->has($field)) {
entries()->registry()->set('fetch.data.'.$field,
parsers()->shortcodes()->process(entries()->registry()->get('fetch.data.'.$field), $cache));
}
}
}
}
@@ -44,5 +40,5 @@ function processParsersField(): void
}
}
}
}
});
}