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.
Merge pull request #4465 from magento-mpi/pr_2019_07_12
[mpi] MAGETWO-98825: [Magento Cloud] When creating a new category, the Category Permissions are set to Deny by default
- Loading branch information
Showing
15 changed files
with
354 additions
and
37 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
64 changes: 64 additions & 0 deletions
64
app/code/Magento/Catalog/Model/Category/StoreCategories.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,64 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Category; | ||
|
||
use Magento\Catalog\Api\CategoryRepositoryInterface; | ||
use Magento\Catalog\Model\Category; | ||
use Magento\Store\Api\GroupRepositoryInterface; | ||
|
||
/** | ||
* Fetcher for associated with store group categories. | ||
*/ | ||
class StoreCategories | ||
{ | ||
/** | ||
* @var CategoryRepositoryInterface | ||
*/ | ||
private $categoryRepository; | ||
|
||
/** | ||
* @var GroupRepositoryInterface | ||
*/ | ||
private $groupRepository; | ||
|
||
/** | ||
* @param CategoryRepositoryInterface $categoryRepository | ||
* @param GroupRepositoryInterface $groupRepository | ||
*/ | ||
public function __construct( | ||
CategoryRepositoryInterface $categoryRepository, | ||
GroupRepositoryInterface $groupRepository | ||
) { | ||
$this->categoryRepository = $categoryRepository; | ||
$this->groupRepository = $groupRepository; | ||
} | ||
|
||
/** | ||
* Get all category ids for store. | ||
* | ||
* @param int|null $storeGroupId | ||
* @return int[] | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
*/ | ||
public function getCategoryIds(?int $storeGroupId = null): array | ||
{ | ||
$rootCategoryId = $storeGroupId | ||
? $this->groupRepository->get($storeGroupId)->getRootCategoryId() | ||
: Category::TREE_ROOT_ID; | ||
/** @var Category $rootCategory */ | ||
$rootCategory = $this->categoryRepository->get($rootCategoryId); | ||
$categoriesIds = array_map( | ||
function ($value) { | ||
return (int) $value; | ||
}, | ||
(array) $rootCategory->getAllChildren(true) | ||
); | ||
|
||
return $categoriesIds; | ||
} | ||
} |
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
112 changes: 112 additions & 0 deletions
112
app/code/Magento/Paypal/Model/Express/LocaleResolver.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,112 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Paypal\Model\Express; | ||
|
||
use Magento\Framework\Locale\ResolverInterface; | ||
use Magento\Paypal\Model\ConfigFactory; | ||
use Magento\Paypal\Model\Config; | ||
|
||
/** | ||
* Resolves locale for PayPal Express. | ||
*/ | ||
class LocaleResolver implements ResolverInterface | ||
{ | ||
/** | ||
* @var ResolverInterface | ||
*/ | ||
private $resolver; | ||
|
||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* Mapping Magento locales on PayPal locales. | ||
* | ||
* @var array | ||
*/ | ||
private $localeMap = [ | ||
'zh_Hans_CN' => 'zh_CN', | ||
'zh_Hant_HK' => 'zh_HK', | ||
'zh_Hant_TW' => 'zh_TW' | ||
]; | ||
|
||
/** | ||
* @param ResolverInterface $resolver | ||
* @param ConfigFactory $configFactory | ||
*/ | ||
public function __construct(ResolverInterface $resolver, ConfigFactory $configFactory) | ||
{ | ||
$this->resolver = $resolver; | ||
$this->config = $configFactory->create(); | ||
$this->config->setMethod(Config::METHOD_EXPRESS); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getDefaultLocalePath() | ||
{ | ||
return $this->resolver->getDefaultLocalePath(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setDefaultLocale($locale) | ||
{ | ||
return $this->resolver->setDefaultLocale($locale); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getDefaultLocale() | ||
{ | ||
return $this->resolver->getDefaultLocale(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setLocale($locale = null) | ||
{ | ||
return $this->resolver->setLocale($locale); | ||
} | ||
|
||
/** | ||
* Gets store's locale or the `en_US` locale if store's locale does not supported by PayPal. | ||
* | ||
* @return string | ||
* @see https://developer.paypal.com/docs/api/reference/locale-codes/#supported-locale-codes | ||
*/ | ||
public function getLocale(): string | ||
{ | ||
$locale = $this->localeMap[$this->resolver->getLocale()] ?? $this->resolver->getLocale(); | ||
$allowedLocales = $this->config->getValue('supported_locales'); | ||
|
||
return strpos($allowedLocales, $locale) !== false ? $locale : 'en_US'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function emulate($scopeId) | ||
{ | ||
return $this->resolver->emulate($scopeId); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function revert() | ||
{ | ||
return $this->resolver->revert(); | ||
} | ||
} |
Oops, something went wrong.