本文整理汇总了PHP中GraphQL\Utils::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::filter方法的具体用法?PHP Utils::filter怎么用?PHP Utils::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphQL\Utils
的用法示例。
在下文中一共展示了Utils::filter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImplementationsIncludingField
/**
* Return implementations of `type` that include `fieldName` as a valid field.
*
* @param Schema $schema
* @param AbstractType $type
* @param $fieldName
* @return array
*/
static function getImplementationsIncludingField(Schema $schema, AbstractType $type, $fieldName)
{
$types = $schema->getPossibleTypes($type);
$types = Utils::filter($types, function ($t) use($fieldName) {
return isset($t->getFields()[$fieldName]);
});
$types = Utils::map($types, function ($t) {
return $t->name;
});
sort($types);
return $types;
}
示例2: __invoke
public function __invoke(ValidationContext $context)
{
$operationCount = 0;
return [NodeKind::DOCUMENT => function (DocumentNode $node) use(&$operationCount) {
$tmp = Utils::filter($node->definitions, function ($definition) {
return $definition->kind === NodeKind::OPERATION_DEFINITION;
});
$operationCount = count($tmp);
}, NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use(&$operationCount, $context) {
if (!$node->name && $operationCount > 1) {
$context->reportError(new Error(self::anonOperationNotAloneMessage(), [$node]));
}
}];
}