Automattic\WooCommerce\Vendor\GraphQL\Error
Error::getLocations
An array of locations within the source Automattic\WooCommerce\Vendor\GraphQL document which correspond to this error.
Each entry has information about line and column within source Automattic\WooCommerce\Vendor\GraphQL document: $location->line; $location->column;
Errors during validation often contain multiple locations, for example to point out to field mentioned in multiple fragments. Errors during execution include a single location, the field which produced the error.
Method of the class: Error{}
No Hooks.
Returns
array<int, SourceLocation>.
Usage
$Error = new Error(); $Error->getLocations(): array;
Error::getLocations() Error::getLocations code WC 11.1.2
public function getLocations(): array
{
if (! isset($this->locations)) {
$positions = $this->getPositions();
$source = $this->getSource();
$nodes = $this->getNodes();
$this->locations = [];
if ($source !== null && $positions !== []) {
foreach ($positions as $position) {
$this->locations[] = $source->getLocation($position);
}
} elseif ($nodes !== null && $nodes !== []) {
foreach ($nodes as $node) {
if (isset($node->loc->source)) {
$this->locations[] = $node->loc->source->getLocation($node->loc->start);
}
}
}
}
return $this->locations;
}