Skip to content

Commit

Permalink
FRW-7936 Allow to provide store name as part of URL path. (#2529)
Browse files Browse the repository at this point in the history
FRW-7936 Allow to provide store name as part of URL path.
  • Loading branch information
dimitriyTsemma authored Nov 28, 2024
1 parent 0823924 commit a68d3c9
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"php": ">=8.2"
},
"require-dev": {
"spryker/code-sniffer": "*"
"spryker/code-sniffer": "*",
"spryker/symfony": "*"
},
"suggest": {
"spryker/symfony": "You need to install this module when you want to use the Storage Router plugin."
},
"autoload": {
"psr-4": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace SprykerShop\Yves\StorageRouterExtension\Dependency\Plugin;

use Symfony\Component\Routing\RequestContext;

interface StorageRouterEnhancerPluginInterface
{
/**
* Specification:
* - Returns a manipulated pathinfo.
* - Can be used to e.g. remove optional prefix from pathinfo.
*
* Symfony's routing component doesn't allow to have optional URL parameter before non-optional ones.
*
* We need to allow projects to use optional arguments in the URL e.g. `/{store}/{locale}/foo-bar`.
* The configured route will only have an URL like `/foo-bar` without the optional arguments but we need to be able
* to match an incoming route like `/de/de/foo-bar` to the configured one.
*
* This method will "normalize" the incoming URL to be matchable.
*
* @api
*
* @param string $pathinfo
* @param \Symfony\Component\Routing\RequestContext $requestContext
*
* @return string
*/
public function beforeMatch(string $pathinfo, RequestContext $requestContext): string;

/**
* Specification:
* - Adds additional information to the matched $parameters.
*
* @api
*
* @param array<mixed> $parameters
* @param \Symfony\Component\Routing\RequestContext $requestContext
*
* @return array<mixed>
*/
public function afterMatch(array $parameters, RequestContext $requestContext): array;

/**
* Specification:
* - Returns a manipulated url after it was generated.
* - Can be used to e.g. add an optional argument to the URL.
*
* Symfony's routing component doesn't allow to have optional URL parameter before non-optional ones.
*
* We need to allow projects to use optional arguments in the URL e.g. `/{store}/{locale}/foo-bar`.
* The configured route will only have an URL like `/foo-bar` with a route name e.g. `foo-bar`. After the generator
* was able to generate an URL by the given route name we need to add the optional arguments to
* return an URL like `/de/de/foo-bar`.
*
* This method will "normalize" the outgoing URL after it was generated.
*
* @api
*
* @param string $url
* @param \Symfony\Component\Routing\RequestContext $requestContext
* @param int $referenceType
*
* @return string
*/
public function afterGenerate(string $url, RequestContext $requestContext, int $referenceType): string;
}

0 comments on commit a68d3c9

Please sign in to comment.