-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alexmerlin <[email protected]>
- Loading branch information
1 parent
23c74de
commit 0e3b857
Showing
11 changed files
with
135 additions
and
24 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 |
---|---|---|
|
@@ -2,38 +2,28 @@ | |
|
||
## Supported Versions | ||
|
||
|
||
| Version | Supported | PHP Version | | ||
|---------|--------------------|---------------------------------------------------------------------------------------------------------------| | ||
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-navigation/3.4.2)| | ||
|
||
| Version | Supported | PHP Version | | ||
|---------|--------------------|----------------------------------------------------------------------------------------------------------------| | ||
| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-navigation/4.0.0) | | ||
| <= 3.x | :x: | | | ||
|
||
## Reporting Potential Security Issues | ||
|
||
If you have encountered a potential security vulnerability in this project, | ||
please report it to us at <[email protected]>. We will work with you to | ||
verify the vulnerability and patch it. | ||
If you have encountered a potential security vulnerability in this project, please report it to us at <[email protected]>. | ||
We will work with you to verify the vulnerability and patch it. | ||
|
||
When reporting issues, please provide the following information: | ||
|
||
- Component(s) affected | ||
- A description indicating how to reproduce the issue | ||
- A summary of the security vulnerability and impact | ||
|
||
We request that you contact us via the email address above and give the | ||
project contributors a chance to resolve the vulnerability and issue a new | ||
release prior to any public exposure; this helps protect the project's | ||
users, and provides them with a chance to upgrade and/or update in order to | ||
protect their applications. | ||
|
||
We request that you contact us via the email address above and give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure; | ||
this helps protect the project's users, and provides them with a chance to upgrade and/or update in order to protect their applications. | ||
|
||
## Policy | ||
|
||
If we verify a reported security vulnerability, our policy is: | ||
|
||
- We will patch the current release branch, as well as the immediate prior minor | ||
release branch. | ||
|
||
- After patching the release branches, we will immediately issue new security | ||
fix releases for each patched release branch. | ||
|
||
- We will patch the current release branch, as well as the immediate prior minor release branch. | ||
- After patching the release branches, we will immediately issue new security fix releases for each patched release branch. |
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 @@ | ||
# Components | ||
|
||
A menu, or navigation container, is a class implementing the \RecursiveIterator interface. It has a hierarchical structure, with nodes called pages(see the `Page` class) that may have children. It is basically a tree | ||
|
||
A Page extends the NavigationContainer class. The NavigationContainer is the top most node which represents the entire menu. The children of this node are Page instances that defines each navigation item. | ||
|
||
A page has a reference to its parent, and can have options and attributes. There are no limitation on what is accepted as options or attributes. | ||
|
||
Options can be any piece of information that describes a page. Some predefined options exists, in order for the navigation module to work seamlessly with other dot modules. | ||
|
||
Attributes are key value pairs that defines the menu item. They are usually inserted as html attributes when parsing the menu, but of course, this is implementation specific. | ||
|
||
A `NavigationService` class, is the service that handles all defined menu container. It can fetch the container from its provider, check if a page is active or not and get the page's generated URI. |
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,7 @@ | ||
# Configuration | ||
|
||
After installation, register `dot-navigation` in your project by adding the below line to your configuration aggregator (usually: `config/config.php`): | ||
|
||
Dot\Navigation\ConfigProvider::class, | ||
|
||
Locate dot-navigation's distributable config file `vendor/dotkernel/dot-navigation/config/autoload/navigation.global.php.dist` and duplicate it in your project as `config/autoload/navigation.global.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,7 @@ | ||
# Container providers | ||
|
||
Each menu can be created from different sources. The responsibility of creating a menu container from the source falls on a container provider. | ||
|
||
Each provider must implement the interface `ProviderInterface` and be registered in the ProviderPluginManager. | ||
|
||
We offer just one provider for now, `ArrayProvider`, that is able to fetch and create a menu container from a php array that is defined in the configuration file. |
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,5 @@ | ||
# Installation | ||
|
||
Install `dotkernel/dot-navigation` by executing the following Composer command: | ||
|
||
composer require dotkernel/dot-navigation |
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,11 @@ | ||
# NavigationRenderer | ||
|
||
Used to render the navigation container in a displayable format. It can render a simple HTML ul list or use a partial template, to render the menu in a template engine. | ||
|
||
The partial method is usually the more flexible one, custom rules can be defined and checked in the template. | ||
|
||
If you are using twig, there is already a twig extension provided in package dot-twigrenderer, that you can use to easily parse the menus inside your templates | ||
|
||
When using the partial method, the template will receive as parameters the container, the navigation service and any extra parameters set by the developer. | ||
|
||
Navigation containers are referred, when parsed, by their name, as defined in the configuration file. |
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,3 @@ | ||
# Overview | ||
|
||
`dot-navigation` is Dotkernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach. |
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,7 @@ | ||
# Required page options and attributes | ||
|
||
The following are options that each page should define in the configuration | ||
|
||
* `label` - the text of the menu item | ||
* `route` or `uri` - defines the route or link the menu item will have | ||
* `permission` - can be used optionally, if authorization service is present, in order to omit menu items that are not authorized to visit. |
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,58 @@ | ||
# Usage | ||
|
||
Below is an example with content of `config/autoload/navigation.global.php`. | ||
|
||
Here we can change or modify the menu structure that will be rendered in the application we are building. | ||
|
||
```php | ||
<?php | ||
|
||
return [ | ||
'dot_navigation' => [ | ||
//enable menu item active if any child is active | ||
'active_recursion' => true, | ||
|
||
//map a provider name to its config | ||
'containers' => [ | ||
'default' => [ | ||
'type' => 'ArrayProvider', | ||
'options' => [ | ||
'items' => [ | ||
[ | ||
'options' => [ | ||
'label' => 'Menu #1', | ||
'route' => [ | ||
'route_name' => 'home', | ||
'route_params' => [], | ||
'query_params' => [], | ||
'fragment_id' => null, | ||
'options' => [], | ||
|
||
//the below parameters are not used in route generation | ||
//they are used in finding if a page is active by omitting some parameters from the check | ||
'ignore_params' => [] | ||
], | ||
], | ||
'attributes' => [ | ||
'name' => 'Menu #1', | ||
] | ||
], | ||
[ | ||
'options' => [ | ||
'label' => 'Menu #2', | ||
'route' => ['route_name' => 'home'], | ||
], | ||
'attributes' => [ | ||
'name' => 'Menu #1', | ||
] | ||
] | ||
], | ||
], | ||
], | ||
], | ||
|
||
//register custom providers here | ||
'provider_manager' => [], | ||
], | ||
]; | ||
``` |
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