|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\GraphQl\Model\Query\Resolver; |
| 9 | + |
| 10 | +use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; |
| 11 | + |
| 12 | +/** |
| 13 | + * Do not use this class. It was kept for backward compatibility. |
| 14 | + * |
| 15 | + * @deprecated \Magento\GraphQl\Model\Query\Context is used instead of this |
| 16 | + */ |
| 17 | +class Context extends \Magento\Framework\Model\AbstractExtensibleModel implements ContextInterface |
| 18 | +{ |
| 19 | + /**#@+ |
| 20 | + * Constants defined for type of context |
| 21 | + */ |
| 22 | + const USER_TYPE_ID = 'user_type'; |
| 23 | + const USER_ID = 'user_id'; |
| 24 | + /**#@-*/ |
| 25 | + |
| 26 | + /** |
| 27 | + * Get extension attributes |
| 28 | + * |
| 29 | + * @return \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface |
| 30 | + */ |
| 31 | + public function getExtensionAttributes() : \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface |
| 32 | + { |
| 33 | + return $this->_getExtensionAttributes(); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Set extension attributes |
| 38 | + * |
| 39 | + * @param \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes |
| 40 | + * @return ContextInterface |
| 41 | + */ |
| 42 | + public function setExtensionAttributes( |
| 43 | + \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes |
| 44 | + ) : ContextInterface { |
| 45 | + return $this->_setExtensionAttributes($extensionAttributes); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Get user id |
| 50 | + * |
| 51 | + * @return int |
| 52 | + */ |
| 53 | + public function getUserId() : int |
| 54 | + { |
| 55 | + return (int) $this->getData(self::USER_ID); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Set user id |
| 60 | + * |
| 61 | + * @param int $userId |
| 62 | + * @return ContextInterface |
| 63 | + */ |
| 64 | + public function setUserId(int $userId) : ContextInterface |
| 65 | + { |
| 66 | + return $this->setData(self::USER_ID, $userId); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Get user type |
| 71 | + * |
| 72 | + * @return int |
| 73 | + */ |
| 74 | + public function getUserType() : int |
| 75 | + { |
| 76 | + return (int) $this->getData(self::USER_TYPE_ID); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Set user type |
| 81 | + * |
| 82 | + * @param int $typeId |
| 83 | + * @return ContextInterface |
| 84 | + */ |
| 85 | + public function setUserType(int $typeId) : ContextInterface |
| 86 | + { |
| 87 | + return $this->setData(self::USER_TYPE_ID, $typeId); |
| 88 | + } |
| 89 | +} |
0 commit comments