Skip to content

Commit d302919

Browse files
committed
fixing issues from review
1 parent 6614c05 commit d302919

7 files changed

Lines changed: 37 additions & 22 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ It provides base classes for action based controllers similar to Laminas control
2020

2121
Install `dot-controller` by executing the following Composer command:
2222

23-
```bash
23+
```bash
2424
$ composer require dotkernel/dot-controller
2525
```
2626

@@ -35,6 +35,7 @@ Middleware controllers act as a handler for multiple routes. Some conventions we
3535
In order to create your action based controllers, you must extend the abstract class `DotKernel\DotController\AbstractActionController`
3636

3737
### Example
38+
3839
Creating a UserController with default action and a register action. Will handle routes `/user` and `/user/register`
3940

4041
```php

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"config": {
5656
"sort-packages": true,
5757
"allow-plugins": {
58-
"dealerdirect/phpcodesniffer-composer-installer": true
58+
"dealerdirect/phpcodesniffer-composer-installer": true,
59+
"laminas/laminas-dependency-plugin": true
5960
}
6061
}
6162
}

docs/book/v3/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Configuration
22

33
After installation, the package can be used immediately but if you want to use all features of the package, like plugins and events you need to register the `ConfigProvider` in your project by adding the below line to your configuration aggregator (usually: `config/config.php`):
4-
4+
55
\Dot\Controller\ConfigProvider::class

docs/book/v3/events.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ DotKernel's controller package supports events and those events can be of 2 type
44

55
## Getting started
66

7-
- Every event listener that is triggered from a controller
7+
- Every event listener that is triggered from a controller
88
needs to implement `Dot\Controller\Event\ControllerEventListenerInterface` which actually extends `Laminas\EventManager\ListenerAggregateInterface`.
99
- You can add the trait `Dot\Controller\Event\ControllerEventListenerTrait` to override the method of the interface.
1010
- Every event listener needs to be registered under the `['dot_controller']['event_listenenrs]` key in the ConfigProvider, and every key must be the class that you want to attach the events
1111

12-
1312
## Usage
1413

1514
The events in a controller can be done in 2 different ways, a global way where an event is attached automatically to all the controllers action and works in the same way the middlewares works
@@ -43,6 +42,7 @@ class UserController extends AbstractActionController
4342
### Example 1 - Global way
4443

4544
First we will create the event listener
45+
4646
```php
4747
use Dot\Controller\Event\ControllerEvent;
4848
use Dot\Controller\Event\ControllerEventListenerInterface;
@@ -84,9 +84,9 @@ after the controller is dispatched.
8484

8585
With this it doesn't matter what action is accessed, the event it will run before and after the action.
8686

87-
In addition, you can make use of the `event` variable to access information about the event.
87+
In addition, you can make use of the `event` variable to access information about the event.
8888

89-
For example:
89+
For example:
9090

9191
```php
9292
// UserUpdatedListener
@@ -101,8 +101,10 @@ public function onAfterDispatch(ControllerEvent $e): void
101101
}
102102
```
103103

104-
So every time the `updateAction` is accessed and the method is post, right after the action is dispatched, we can log that the user was updated. <br>
105-
We can use the `onBeforeDispatch` in the same way, to log right before the user is updated.
104+
So every time the `updateAction` is accessed and the method is post,
105+
right after the action is dispatched, we can log that the user was updated.
106+
107+
We can use the `onBeforeDispatch` in the same way, to log right before the user is updated.
106108

107109
### Example 2 - Manually triggered way
108110

@@ -134,8 +136,10 @@ class UserUpdatedListener implements ControllerEventListenerInterface
134136
}
135137
```
136138

137-
The `attach` method is from the `ListenerAggregateInterface` which `ControllerEventListenerTrait` already is overriding it so can be used in a global way
138-
with `onBeforeDispatch` and `onAfterDispatch` methods, but we can make our custom event and bind it to our method. <br>
139+
The `attach` method is from the `ListenerAggregateInterface` which `ControllerEventListenerTrait`
140+
already is overriding it so can be used in a global way with `onBeforeDispatch` and `onAfterDispatch`
141+
methods, but we can make our custom event and bind it to our method.
142+
139143
In this case we create attach an event called `user.profile.update` and bind it to the `userProfileUpdated` method.
140144

141145
Next we need to register the event

docs/book/v3/plugins.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ DotKernel's controller support plugins, much like controllers in a Laminas Appli
44
The package comes packed with a few built in plugins, but you can extend controller functionality with your own plugins.
55

66
## Usage
7-
Any controller plugins must implement `Dot\Controller\Plugin\PluginInterface`.
8-
You need to create a factory in addition to the plugin and register it under the `['dot_controller']['plugin_manager']['factories']` with the plugin name. <br>
97

10-
Once registered, a plugin can be directly accessed in any controller, by calling a method with the plugin's name(the service name or the key at which the plugin is registered inside the manager) <br>
11-
Controller plugins offer the advantage of globally accessible functionality in any controller without to manually inject dependencies. Plugins should be used for functions that are common to any controller. Do not clutter controller's code with unnecessary plugins.
8+
Any controller plugins must implement `Dot\Controller\Plugin\PluginInterface`.
9+
You need to create a factory in addition to the plugin and register it
10+
under the `['dot_controller']['plugin_manager']['factories']` with the plugin name.
11+
12+
Once registered, a plugin can be directly accessed in any controller,
13+
by calling a method with the plugin's name (the service name or the key at which the plugin is registered inside the manager)
14+
15+
Controller plugins offer the advantage of globally accessible functionality
16+
in any controller without to manually inject dependencies.
17+
Plugins should be used for functions that are common to any controller.
18+
Do not clutter controller's code with unnecessary plugins.
1219

1320
### Example
1421

15-
First we create our desired plugin, for our example a string helper
22+
First we create our desired plugin, for our example a string helper
1623

1724
```php
1825
class StringPlugin implements PluginInterface
@@ -54,7 +61,8 @@ Register the factory under the `['dot_controller']['plugin_manager']['factories'
5461
]
5562
```
5663

57-
You don't need to register the plugin factory to a regular dependencies in a configuration because `AbstractPluginManager` actually extends `ServiceManager`
64+
You don't need to register the plugin factory to a regular dependencies in a configuration
65+
because `AbstractPluginManager` actually extends `ServiceManager`
5866

5967
Access it in a controller.
6068

@@ -66,11 +74,10 @@ $this->string()->toUpper("test") // will return TEST
6674

6775
## Build-in plugins
6876

69-
The package comes in with 2 default plugins ``template`` and `url`. You can use
77+
The package comes in with 2 default plugins ``template`` and `url`. You can use
7078
them in the same way as our example above.
7179

72-
- Url plugin
73-
- - the plugin is an instance of `Mezzio\Helper\UrlHelper`
80+
- `url` - the plugin is an instance of `Mezzio\Helper\UrlHelper`
7481

7582
```php
7683
//in a controller action
@@ -79,8 +86,7 @@ them in the same way as our example above.
7986
echo $url->generate('account', ['action' => 'foo', 'hash' => 'bar'])
8087
```
8188

82-
- Template plugin
83-
- - the plugin is an instance of `Mezzio\Template\TemplateRendererInterface`
89+
- `template` - the plugin is an instance of `Mezzio\Template\TemplateRendererInterface`
8490

8591
```php
8692
// in a controller action

docs/book/v3/usage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Middleware controllers act as a handler for multiple routes. Some conventions we
99
In order to create your action based controllers, you must extend the abstract class `DotKernel\DotController\AbstractActionController`
1010

1111
## Example
12+
1213
Creating a UserController with default action and a register action. Will handle routes `/user` and `/user/register`
1314

1415
```php

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ nav:
1717
site_name: dot-controller
1818
site_description: "DotKernel's controller package"
1919
repo_url: "https://github.com/dotkernel/dot-controller"
20+
plugins:
21+
- search

0 commit comments

Comments
 (0)