Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules
OverlappingFieldsCanBeMerged::collectConflictsBetween
Collect all Conflicts between two collections of fields. This is similar to, but different from the collectConflictsWithin function above. This check assumes that collectConflictsWithin has already been called on each provided collection of fields. This is true because this validator traverses each individual selection set.
Method of the class: OverlappingFieldsCanBeMerged{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->collectConflictsBetween( $context, $conflicts, $parentFieldsAreMutuallyExclusive, $fieldMap1, $fieldMap2 ): void;
- $context(QueryValidationContext) (required)
- .
- $conflicts(array) (required)
- .
- $parentFieldsAreMutuallyExclusive(true|false) (required)
- .
- $fieldMap1(array) (required)
- .
- $fieldMap2(array) (required)
- .
OverlappingFieldsCanBeMerged::collectConflictsBetween() OverlappingFieldsCanBeMerged::collectConflictsBetween code WC 10.9.1
protected function collectConflictsBetween(
QueryValidationContext $context,
array &$conflicts,
bool $parentFieldsAreMutuallyExclusive,
array $fieldMap1,
array $fieldMap2
): void {
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For any response name which appears in both provided field
// maps, each field from the first field map must be compared to every field
// in the second field map to find potential conflicts.
foreach ($fieldMap1 as $responseName => $fields1) {
if (! isset($fieldMap2[$responseName])) {
continue;
}
$fields2 = $fieldMap2[$responseName];
$fields1Length = count($fields1);
$fields2Length = count($fields2);
for ($i = 0; $i < $fields1Length; ++$i) {
for ($j = 0; $j < $fields2Length; ++$j) {
$conflict = $this->findConflict(
$context,
$parentFieldsAreMutuallyExclusive,
$responseName,
$fields1[$i],
$fields2[$j]
);
if ($conflict !== null) {
$conflicts[] = $conflict;
}
}
}
}
}