Skip to content

Commit

Permalink
[1.x] Enhancement: Account for linked fields in JIT scanner (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Sleight <[email protected]>
  • Loading branch information
caseydwyer and jacksleight authored Nov 23, 2023
1 parent 9defc91 commit 58edbd5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/JitSafeScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Statamic\Facades\YAML;
use Statamic\Fields\Blueprint;
use Statamic\Fields\Fieldset;
use Statamic\Support\Arr;

class JitSafeScanner
{
Expand Down Expand Up @@ -78,11 +79,17 @@ protected function findConfigs($data)
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $value) {
if (! is_array($value)) {
if (! is_array($value) || ! Arr::exists($value, 'handle') || ! Arr::exists($value, 'field')) {
continue;
}
if (($value['type'] ?? null) === 'miniset_classes' && is_array($value['fields'] ?? null)) {
$configs[] = $value;
if (is_string($value['field'] ?? null)) {
if ($imports = FieldFacade::find($value['field'])) {
$value['field'] = array_merge($imports->toArray(), $value['config'] ?? []);
}
}
$config = $value['field'];
if (($config['type'] ?? null) === 'miniset_classes' && is_array($config['fields'] ?? null)) {
$configs[] = $config;
}
}

Expand Down

0 comments on commit 58edbd5

Please sign in to comment.