ContextInterface.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Framework\GraphQl\Query\Resolver;
  8. use Magento\Framework\Api\ExtensibleDataInterface;
  9. use Magento\Framework\GraphQl\Query\ResolverInterface;
  10. /**
  11. * Resolver Context is used as a shared data extensible object in all resolvers that implement @see ResolverInterface.
  12. *
  13. * GraphQL will pass the same instance of this interface to each field resolver, so these resolvers could have
  14. * shared access to the same data for ease of implementation purposes.
  15. */
  16. interface ContextInterface extends ExtensibleDataInterface
  17. {
  18. /**
  19. * Get the type of a user
  20. *
  21. * @see \Magento\Authorization\Model\UserContextInterface for corespondent values
  22. *
  23. * @return int
  24. */
  25. public function getUserType() : int;
  26. /**
  27. * Set type of a user
  28. *
  29. * @see \Magento\Authorization\Model\UserContextInterface for corespondent values
  30. *
  31. * @param int $typeId
  32. * @return ContextInterface
  33. */
  34. public function setUserType(int $typeId) : ContextInterface;
  35. /**
  36. * Get id of the user
  37. *
  38. * @return int
  39. */
  40. public function getUserId() : int;
  41. /**
  42. * Set id of a user
  43. *
  44. * @param int $userId
  45. * @return ContextInterface
  46. */
  47. public function setUserId(int $userId) : ContextInterface;
  48. /**
  49. * Retrieve existing extension attributes object or create a new one.
  50. *
  51. * @return \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface
  52. */
  53. public function getExtensionAttributes();
  54. /**
  55. * Set an extension attributes object.
  56. *
  57. * @param \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes
  58. * @return ContextInterface
  59. */
  60. public function setExtensionAttributes(
  61. \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes
  62. ) : ContextInterface;
  63. }