This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#741: Add extension point to set custom parameters to Query Context o…
…bject
- Loading branch information
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\GraphQl\Model\Query\Resolver; | ||
|
||
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; | ||
|
||
/** | ||
* Do not use this class. It was kept for backward compatibility. | ||
* | ||
* @deprecated \Magento\GraphQl\Model\Query\Context is used instead of this | ||
*/ | ||
class Context extends \Magento\Framework\Model\AbstractExtensibleModel implements ContextInterface | ||
{ | ||
/**#@+ | ||
* Constants defined for type of context | ||
*/ | ||
const USER_TYPE_ID = 'user_type'; | ||
const USER_ID = 'user_id'; | ||
/**#@-*/ | ||
|
||
/** | ||
* Get extension attributes | ||
* | ||
* @return \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface | ||
*/ | ||
public function getExtensionAttributes() : \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface | ||
{ | ||
return $this->_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); | ||
} | ||
} |