Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
#741: Add extension point to set custom parameters to Query Context o…
Browse files Browse the repository at this point in the history
…bject
  • Loading branch information
naydav committed Jun 19, 2019
1 parent 0d505fe commit 28aaefa
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions app/code/Magento/GraphQl/Model/Query/Resolver/Context.php
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);
}
}

0 comments on commit 28aaefa

Please sign in to comment.