forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request magento#3251 from magento-engcom/graphql-develop-prs
[EngCom] Public Pull Requests - GraphQL
- Loading branch information
Showing
28 changed files
with
748 additions
and
180 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
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
55 changes: 55 additions & 0 deletions
55
...gento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ExtractDataFromCategoryTree.php
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,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider; | ||
|
||
use Magento\CatalogGraphQl\Model\Category\Hydrator; | ||
use Magento\Catalog\Api\Data\CategoryInterface; | ||
|
||
/** | ||
* Extract data from category tree | ||
*/ | ||
class ExtractDataFromCategoryTree | ||
{ | ||
/** | ||
* @var Hydrator | ||
*/ | ||
private $categoryHydrator; | ||
|
||
/** | ||
* @param Hydrator $categoryHydrator | ||
*/ | ||
public function __construct( | ||
Hydrator $categoryHydrator | ||
) { | ||
$this->categoryHydrator = $categoryHydrator; | ||
} | ||
|
||
/** | ||
* Extract data from category tree | ||
* | ||
* @param \Iterator $iterator | ||
* @return array | ||
*/ | ||
public function execute(\Iterator $iterator): array | ||
{ | ||
$tree = []; | ||
while ($iterator->valid()) { | ||
/** @var CategoryInterface $category */ | ||
$category = $iterator->current(); | ||
$iterator->next(); | ||
$nextCategory = $iterator->current(); | ||
$tree[$category->getId()] = $this->categoryHydrator->hydrateCategory($category); | ||
$tree[$category->getId()]['model'] = $category; | ||
if ($nextCategory && (int) $nextCategory->getLevel() !== (int) $category->getLevel()) { | ||
$tree[$category->getId()]['children'] = $this->execute($iterator); | ||
} | ||
} | ||
|
||
return $tree; | ||
} | ||
} |
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
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
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
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,21 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider"> | ||
<arguments> | ||
<argument name="extendedConfigData" xsi:type="array"> | ||
<item name="front" xsi:type="string">web/default/front</item> | ||
<item name="cms_home_page" xsi:type="string">web/default/cms_home_page</item> | ||
<item name="no_route" xsi:type="string">web/default/no_route</item> | ||
<item name="cms_no_route" xsi:type="string">web/default/cms_no_route</item> | ||
<item name="cms_no_cookies" xsi:type="string">web/default/cms_no_cookies</item> | ||
<item name="show_cms_breadcrumbs" xsi:type="string">web/default/show_cms_breadcrumbs</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
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
67 changes: 67 additions & 0 deletions
67
app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/Account/RevokeCustomerToken.php
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,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CustomerGraphQl\Model\Resolver\Customer\Account; | ||
|
||
use Magento\Authorization\Model\UserContextInterface; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Integration\Api\CustomerTokenServiceInterface; | ||
|
||
/** | ||
* Customers Revoke Token resolver, used for GraphQL request processing. | ||
*/ | ||
class RevokeCustomerToken implements ResolverInterface | ||
{ | ||
/** | ||
* @var UserContextInterface | ||
*/ | ||
private $userContext; | ||
|
||
/** | ||
* @var CustomerTokenServiceInterface | ||
*/ | ||
private $customerTokenService; | ||
|
||
/** | ||
* @param UserContextInterface $userContext | ||
* @param CustomerTokenServiceInterface $customerTokenService | ||
*/ | ||
public function __construct( | ||
UserContextInterface $userContext, | ||
CustomerTokenServiceInterface $customerTokenService | ||
) { | ||
$this->userContext = $userContext; | ||
$this->customerTokenService = $customerTokenService; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
$customerId = (int)$this->userContext->getUserId(); | ||
|
||
if ($customerId === 0) { | ||
throw new GraphQlAuthorizationException( | ||
__( | ||
'Current customer does not have access to the resource "%1"', | ||
[\Magento\Customer\Model\Customer::ENTITY] | ||
) | ||
); | ||
} | ||
|
||
return $this->customerTokenService->revokeCustomerAccessToken($customerId); | ||
} | ||
} |
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
Oops, something went wrong.