From 96ca94c14752c60a7460e7b987cffcdd652e1627 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 3 Oct 2016 08:17:55 +1300 Subject: [PATCH] DataObjectInterfaceCreator Useful if types want to implement more than one interface --- src/DataObjectInterfaceTypeCreator.php | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/DataObjectInterfaceTypeCreator.php diff --git a/src/DataObjectInterfaceTypeCreator.php b/src/DataObjectInterfaceTypeCreator.php new file mode 100644 index 000000000..26c49e2ae --- /dev/null +++ b/src/DataObjectInterfaceTypeCreator.php @@ -0,0 +1,48 @@ + 'DataObject', + 'description' => 'Base Interface', + ]; + } + + public function fields() { + return [ + 'id' => [ + 'type' => Type::nonNull(Type::int()), + ], + 'created' => [ + 'type' => Type::string(), + ], + 'lastEdited' => [ + 'type' => Type::string(), + ], + + ]; + } + + public function resolveType($object) + { + $type = null; + + if($fqnType = $this->manager->getType(get_class($object))) { + $type = $fqnType; + } + + if($baseType = $this->manager->getType(get_class($object))) { + $type = $baseType; + } + + return $type; + } + +}