Skip to content

Commit

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

FRW-7936 Integration.
  • Loading branch information
asmarovydlo authored Dec 12, 2024
2 parents f03317f + 24cffe6 commit a2dce5b
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 81 deletions.
219 changes: 139 additions & 80 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 @@ -68,6 +68,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\MessageBroker\MessageBrokerConstants;
Expand Down Expand Up @@ -129,6 +130,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 @@ -167,6 +170,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 @@ -149,8 +149,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 Commerce OS.
* 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 @@ -12,6 +12,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 @@ -29,4 +30,14 @@ protected function getResourceCreatorPlugins(): array
new RedirectResourceCreatorPlugin(),
];
}

/**
* @return array<\SprykerShop\Yves\StorageRouterExtension\Dependency\Plugin\StorageRouterEnhancerPluginInterface>
*/
protected function getStorageRouterEnhancerPlugins(): array
{
return [
new StorePrefixStorageRouterEnhancerPlugin(),
];
}
}
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 @@ -24,6 +25,8 @@ public function getCodeBuckets(): array
return [
'EU',
'US',
'DE',
'AT',
];
}

Expand All @@ -40,6 +43,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 @@ -50,4 +58,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 All @@ -31,6 +32,11 @@ class CustomerPresentationTester extends Actor
{
use _generated\CustomerPresentationTesterActions;

/**
* @var string
*/
protected const URL_STORE_PREFIX = '/DE';

/**
* @param string $email
* @param string $password
Expand Down Expand Up @@ -62,4 +68,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', static::URL_STORE_PREFIX, $uri);
}

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

0 comments on commit a2dce5b

Please sign in to comment.