Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
registering of FriendlyUrlDataProviders is now done via service conta…
…iner - documentation about friendly url has been added
- Loading branch information
1 parent
7221484
commit 79de76b
Showing
15 changed files
with
84 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Friendly URL | ||
|
||
Shopsys Framework comes with the implementation to support custom URLs for entities or other use you might need. | ||
By default, there are custom URLs implemented for `Product` detail, `Product` list, `Article` detail and `Brand` detail pages. | ||
Thanks to this functionality you can set your own URL or set of URLs to these entities. | ||
This functionality is provided by `FriendlyUrlDataProviderInterface` implementations, e.g. `\Shopsys\FrameworkBundle\Model\Product\ProductDetailFriendlyUrlDataProvider`. | ||
Such classes are automatically registered in `FriendlyUrlDataProviderRegistry`. | ||
The rest of the work is done automatically and URLs provided by these providers are now accessible via browser. | ||
|
||
## How to create new `FriendlyUrlDataProvider` | ||
|
||
- create new class with name ending with `FriendlyUrlDataProvider` | ||
- this class has to implement `FriendlyUrlDataProviderInterface` | ||
- this interface requires you to implement two methods *(see `ProductDetailFriendlyUrlDataProvider` class as an example of the implementation)*: | ||
- `getFriendlyUrlData` method that generates `FriendlyUrlData` for all your entities | ||
- `getRouteName` method returns name of route that you have to declare in `routing_friendly_url.yml` file like: | ||
``` | ||
front_<entity_name>_detail: | ||
path: friendly-url | ||
defaults: { _controller: ShopsysShopBundle:Front\<entity_name>:detail } | ||
``` | ||
this will route all URLs you have provided in `getFriendlyUrlData` method to `<entity_name>Controller::detailAction` method and provide you with ID of entity matching that URL | ||
*(see [Symfony Documentation](https://symfony.com/doc/3.4/controller.html) to learn how to create new `Controller`)* | ||
- visit some of provided URLs and check if everything works fine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
...Component/Router/FriendlyUrl/CompilerPass/RegisterFriendlyUrlDataProviderCompilerPass.php
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...ception/FriendlyUrlDataProviderMustImplementFriendlyUrlDataProviderInterfaceException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Shopsys\FrameworkBundle\Component\Router\FriendlyUrl\Exception; | ||
|
||
use Exception; | ||
|
||
class FriendlyUrlDataProviderMustImplementFriendlyUrlDataProviderInterfaceException extends Exception implements FriendlyUrlException | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('FriendlyUrlDataProvider must implement FriendlyUrlDataProviderInterface.'); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...Pass/FriendlyUrlDataProviderInterface.php → ...yUrl/FriendlyUrlDataProviderInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters