From 28aaefa35551bd8ab2667db3d86368e9aca06484 Mon Sep 17 00:00:00 2001 From: Valerii Naida Date: Wed, 19 Jun 2019 15:58:21 -0500 Subject: [PATCH] magento/graphql-ce#741: Add extension point to set custom parameters to Query Context object --- .../GraphQl/Model/Query/Resolver/Context.php | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/code/Magento/GraphQl/Model/Query/Resolver/Context.php diff --git a/app/code/Magento/GraphQl/Model/Query/Resolver/Context.php b/app/code/Magento/GraphQl/Model/Query/Resolver/Context.php new file mode 100644 index 0000000000000..2b8e3fabd6863 --- /dev/null +++ b/app/code/Magento/GraphQl/Model/Query/Resolver/Context.php @@ -0,0 +1,89 @@ +_getExtensionAttributes(); + } + + /** + * Set extension attributes + * + * @param \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes + * @return ContextInterface + */ + public function setExtensionAttributes( + \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes + ) : ContextInterface { + return $this->_setExtensionAttributes($extensionAttributes); + } + + /** + * Get user id + * + * @return int + */ + public function getUserId() : int + { + return (int) $this->getData(self::USER_ID); + } + + /** + * Set user id + * + * @param int $userId + * @return ContextInterface + */ + public function setUserId(int $userId) : ContextInterface + { + return $this->setData(self::USER_ID, $userId); + } + + /** + * Get user type + * + * @return int + */ + public function getUserType() : int + { + return (int) $this->getData(self::USER_TYPE_ID); + } + + /** + * Set user type + * + * @param int $typeId + * @return ContextInterface + */ + public function setUserType(int $typeId) : ContextInterface + { + return $this->setData(self::USER_TYPE_ID, $typeId); + } +}