diff --git a/composer.json b/composer.json index 21d97e3..4dd439f 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/SprykerShop/Yves/StorageRouterExtension/Dependency/Plugin/StorageRouterEnhancerPluginInterface.php b/src/SprykerShop/Yves/StorageRouterExtension/Dependency/Plugin/StorageRouterEnhancerPluginInterface.php new file mode 100644 index 0000000..c457d02 --- /dev/null +++ b/src/SprykerShop/Yves/StorageRouterExtension/Dependency/Plugin/StorageRouterEnhancerPluginInterface.php @@ -0,0 +1,72 @@ + $parameters + * @param \Symfony\Component\Routing\RequestContext $requestContext + * + * @return array + */ + 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; +}