Automattic\WooCommerce\Vendor\GraphQL\Type\Definition

ResolveInfo::foldSelectionSetprivateWC 1.0

Метод класса: ResolveInfo{}

Хуков нет.

Возвращает

Массив<Строку,. bool>

Использование

// private - только в коде основоного (родительского) класса
$result = $this->foldSelectionSet( $selectionSet, $descend ): array;
$selectionSet(SelectionSetNode) (обязательный)
.
$descend(int) (обязательный)
.

Код ResolveInfo::foldSelectionSet() WC 11.0.1

private function foldSelectionSet(SelectionSetNode $selectionSet, int $descend): array
{
    /** @var array<string, bool> $fields */
    $fields = [];

    foreach ($selectionSet->selections as $selection) {
        if ($selection instanceof FieldNode) {
            $fields[$selection->name->value] = $descend > 0 && $selection->selectionSet !== null
                ? array_merge_recursive(
                    $fields[$selection->name->value] ?? [],
                    $this->foldSelectionSet($selection->selectionSet, $descend - 1)
                )
                : true;
        } elseif ($selection instanceof FragmentSpreadNode) {
            $spreadName = $selection->name->value;
            $fragment = $this->fragments[$spreadName] ?? null;
            if ($fragment === null) {
                continue;
            }

            $fields = array_merge_recursive(
                $this->foldSelectionSet($fragment->selectionSet, $descend),
                $fields
            );
        } elseif ($selection instanceof InlineFragmentNode) {
            $fields = array_merge_recursive(
                $this->foldSelectionSet($selection->selectionSet, $descend),
                $fields
            );
        }
    }

    return $fields;
}