Source of file InterfaceTypeCreator.php
Size: 1,274 Bytes - Last Modified: 2021-12-23T10:31:47+00:00
/var/www/docs.ssmods.com/process/src/src/InterfaceTypeCreator.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | <?php namespace SilverStripe\GraphQL; use GraphQL\Type\Definition\InterfaceType; /** * Base type creator for interface type generation. * * @link https://github.com/webonyx/graphql-php#interfaces */ class InterfaceTypeCreator extends TypeCreator { /** * Returns a callback to the type resolver for this interface * * @return callable */ protected function getTypeResolver() { if (!method_exists($this, 'resolveType')) { return null; } $resolver = array($this, 'resolveType'); return function () use ($resolver) { $args = func_get_args(); return call_user_func_array($resolver, $args); }; } /** * Get the attributes from the container. * * @return array */ public function getAttributes() { $attributes = parent::getAttributes(); $resolver = $this->getTypeResolver(); if (isset($resolver)) { $attributes['resolveType'] = $resolver; } return $attributes; } /** * Generates the interface type from its configuration * * @return InterfaceType */ public function toType() { return new InterfaceType($this->toArray()); } } |