Skip to content

Commit

Permalink
feat(fields): updates for parsers field #199
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Aug 1, 2021
1 parent 632de23 commit 39fd62d
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/flextype/Foundation/Entries/Fields/ParsersField.php
Expand Up @@ -9,32 +9,28 @@

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));
}
}
}
}
Expand All @@ -44,5 +40,5 @@ function processParsersField(): void
}
}
}
}
});
}

0 comments on commit 39fd62d

Please sign in to comment.