Navigation

URL

The URL module handles dynamic URLs for entities that appear on the front-end (Yves). At the moment, Spryker core provides URL handling for products, CMS pages, categories and URL redirects.

The URLs are stored in one database table and each is unique. The database structure for storing URLs looks like the following:

In the Spryker Demoshop, URLs are exported to the key-value storage (Redis) with collectors. Every stored key contains the URL that can be matched with a router and every stored value contains a reference key and a type.

The reference_key contains the key of the entity that was also stored in the key-value storage. The data read from the reference key is exactly the data that will be provided to the controller to handle the request at the end. The type is required to determine which controller handles the request (along with the data from the reference key).

The example below shows the value stored under the kv:de.en_us.url./en/imprint key which will match the /en/imprint URL in Demoshop.

{
    "reference_key": "de.en_us.resource.page.1",
    "type": "page"
}

A router called \Pyz\Yves\Collector\Plugin\Router\StorageRouter, matches URLs for Yves requests handled by the URL module. If a requested URL is matched with the StorageRouter then it will try to find a ResourceCreator that can handle the provided resource type. ResourceCreator provides data for the router about the controller that will handle the request.

To read more about how to implement a custom ResourceCreator see Setting up the frontend (link to http://spryker.github.io/core/bundles/url/#setting-up-the-frontend).

See also: