Skip to content

Commit

Permalink
Merge pull request #1643 from spryker-shop/feature/frw-7936/master-st…
Browse files Browse the repository at this point in the history
…ore-in-the-url-for-yves

FRW-7936 nonsplit to split merge
  • Loading branch information
gechetspr authored Nov 28, 2024
2 parents ceafc25 + 0c90873 commit 54afff3
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 138 deletions.
287 changes: 150 additions & 137 deletions composer.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions config/Shared/config_default.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
use Spryker\Shared\Http\HttpConstants;
use Spryker\Shared\Kernel\KernelConstants;
use Spryker\Shared\KernelApp\KernelAppConstants;
use Spryker\Shared\Locale\LocaleConstants;
use Spryker\Shared\Log\LogConstants;
use Spryker\Shared\Mail\MailConstants;
use Spryker\Shared\MerchantPortalApplication\MerchantPortalConstants;
Expand Down Expand Up @@ -137,6 +138,8 @@
use Spryker\Zed\Propel\PropelConfig;
use SprykerShop\Shared\CustomerPage\CustomerPageConstants;
use SprykerShop\Shared\ShopUi\ShopUiConstants;
use SprykerShop\Shared\StorageRouter\StorageRouterConstants;
use SprykerShop\Shared\StoreWidget\StoreWidgetConstants;
use Symfony\Component\HttpFoundation\Cookie;

// ############################################################################
Expand Down Expand Up @@ -175,6 +178,12 @@
'healthCheck' => 'health-check/index',
];

$config[RouterConstants::IS_STORE_ROUTING_ENABLED]
= $config[StoreWidgetConstants::IS_STORE_ROUTING_ENABLED]
= $config[StorageRouterConstants::IS_STORE_ROUTING_ENABLED]
= $config[ShopUiConstants::IS_STORE_ROUTING_ENABLED]
= $config[LocaleConstants::IS_STORE_ROUTING_ENABLED] = (bool)getenv('SPRYKER_DYNAMIC_STORE_MODE');

// >>> DEV TOOLS

$config[ConsoleConstants::ENABLE_DEVELOPMENT_CONSOLE_COMMANDS] = (bool)getenv('DEVELOPMENT_CONSOLE_COMMANDS');
Expand Down
8 changes: 8 additions & 0 deletions src/Pyz/Yves/Router/RouterConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ public function getAllowedLanguages(): array
{
return (new Container())->getLocator()->locale()->client()->getAllowedLanguages();
}

/**
* @return array<string>
*/
public function getAllowedStores(): array
{
return (new Container())->getLocator()->storeStorage()->client()->getStoreNames();
}
}
2 changes: 1 addition & 1 deletion src/Pyz/Yves/Router/RouterDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ protected function getPostAddRouteManipulator(): array
protected function getRouterEnhancerPlugins(): array
{
return [
new LanguagePrefixRouterEnhancerPlugin(),
new StorePrefixRouterEnhancerPlugin(),
new LanguagePrefixRouterEnhancerPlugin(),
];
}
}
22 changes: 22 additions & 0 deletions src/Pyz/Yves/StorageRouter/StorageRouterConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* This file is part of the Spryker Suite.
* For full license information, please view the LICENSE file that was distributed with this source code.
*/

namespace Pyz\Yves\StorageRouter;

use Spryker\Client\Kernel\Container;
use SprykerShop\Yves\StorageRouter\StorageRouterConfig as SprykerStorageRouterConfig;

class StorageRouterConfig extends SprykerStorageRouterConfig
{
/**
* @return array<string>
*/
public function getAllowedStores(): array
{
return (new Container())->getLocator()->storeStorage()->client()->getStoreNames();
}
}
11 changes: 11 additions & 0 deletions src/Pyz/Yves/StorageRouter/StorageRouterDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SprykerShop\Yves\ProductDetailPage\Plugin\StorageRouter\ProductDetailPageResourceCreatorPlugin;
use SprykerShop\Yves\ProductSetDetailPage\Plugin\StorageRouter\ProductSetDetailPageResourceCreatorPlugin;
use SprykerShop\Yves\RedirectPage\Plugin\StorageRouter\RedirectResourceCreatorPlugin;
use SprykerShop\Yves\StorageRouter\Plugin\RouterEnhancer\StorePrefixStorageRouterEnhancerPlugin;
use SprykerShop\Yves\StorageRouter\StorageRouterDependencyProvider as SprykerShopStorageRouterDependencyProvider;

class StorageRouterDependencyProvider extends SprykerShopStorageRouterDependencyProvider
Expand All @@ -31,4 +32,14 @@ protected function getResourceCreatorPlugins(): array
new MerchantPageResourceCreatorPlugin(),
];
}

/**
* @return array<\SprykerShop\Yves\StorageRouterExtension\Dependency\Plugin\StorageRouterEnhancerPluginInterface>
*/
protected function getStorageRouterEnhancerPlugins(): array
{
return [
new StorePrefixStorageRouterEnhancerPlugin(),
];
}
}
2 changes: 2 additions & 0 deletions src/Pyz/Yves/Twig/TwigDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use SprykerShop\Yves\ShopCmsSlot\Plugin\Twig\ShopCmsSlotTwigPlugin;
use SprykerShop\Yves\ShopPermission\Plugin\Twig\ShopPermissionTwigPlugin;
use SprykerShop\Yves\ShopUi\Plugin\Twig\FunctionTwigPlugin;
use SprykerShop\Yves\ShopUi\Plugin\Twig\GeneratePathTwigPlugin;
use SprykerShop\Yves\ShopUi\Plugin\Twig\NumberFormatterTwigPlugin;
use SprykerShop\Yves\ShopUi\Plugin\Twig\ShopUiTwigPlugin;
use SprykerShop\Yves\WebProfilerWidget\Plugin\Twig\WebProfilerTwigLoaderPlugin;
Expand Down Expand Up @@ -87,6 +88,7 @@ protected function getTwigPlugins(): array
new ShopCmsSlotTwigPlugin(),
new ContentNavigationTwigPlugin(),
new NumberFormatterTwigPlugin(),
new GeneratePathTwigPlugin(),
];
}

Expand Down
18 changes: 18 additions & 0 deletions src/SprykerConfig/CodeBucketConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Spryker\Shared\Kernel\CodeBucket\Config\AbstractCodeBucketConfig;
use Spryker\Shared\Kernel\Store;
use Symfony\Component\HttpFoundation\Request;

class CodeBucketConfig extends AbstractCodeBucketConfig
{
Expand All @@ -32,6 +33,8 @@ public function getCodeBuckets(): array
return [
'EU',
'US',
'DE',
'AT',
];
}

Expand All @@ -48,6 +51,11 @@ public function getDefaultCodeBucket(): string

$codeBuckets = $this->getCodeBuckets();

$parts = explode('/', $this->getPathInfo());
if (isset($parts[1]) && in_array($parts[1], $codeBuckets, true)) {
return $parts[1];
}

return defined('APPLICATION_REGION') ? APPLICATION_REGION : reset($codeBuckets);
}

Expand All @@ -58,4 +66,14 @@ protected function isAcpDevOn(): bool
{
return APPLICATION_ENV === 'docker.acp.dev';
}

/**
* @return string
*/
protected function getPathInfo(): string
{
$requestFromGlobals = Request::createFromGlobals();

return $requestFromGlobals->getPathInfo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace PyzTest\Yves\Customer;

use Codeception\Actor;
use Codeception\Step\Assertion;
use PyzTest\Yves\Customer\PageObject\CustomerLoginPage;
use PyzTest\Yves\Customer\PageObject\CustomerRegistrationPage;

Expand Down Expand Up @@ -62,4 +63,18 @@ public function fillOutRegistrationForm(): void
$i->fillField(CustomerRegistrationPage::FORM_FIELD_SELECTOR_PASSWORD_CONFIRM, $customerTransfer->getPassword());
$i->click(CustomerRegistrationPage::FORM_FIELD_SELECTOR_ACCEPT_TERMS);
}

/**
* @param string $uri
*
* @return void
*/
public function seeCurrentUrlEquals(string $uri): void
{
if ($this->getLocator()->store()->facade()->isDynamicStoreEnabled() === true) {
$uri = sprintf('%s%s', '/DE', $uri);
}

$this->getScenario()->runStep(new Assertion('seeCurrentUrlEquals', func_get_args()));
}
}

0 comments on commit 54afff3

Please sign in to comment.