Skip to content

Commit b31515a

Browse files
authored
Merge pull request #7 from programmatordev/PAS-5-improve-plugin-system-example
Improve plugin system example and misc
2 parents 1f8358a + 072b761 commit b31515a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
/vendor/
66
/logs/
77
/.idea
8-
/index.php
8+
/index.php
9+
/src/TestApi.php

Diff for: README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class YourApi extends Api
367367

368368
#### `addPreRequestListener`
369369

370-
The `addPreRequestListener` method is used to add a function that is called before a request, and all handled data, has been made.
370+
The `addPreRequestListener` method is used to add a function that is called before a request has been made.
371371
This event listener will be applied to every API request.
372372

373373
```php
@@ -673,8 +673,7 @@ The following list has all the implemented plugins with the respective priority
673673
| [`LoggerPlugin`](https://docs.php-http.org/en/latest/plugins/logger.html) | 8 | only if logger is enabled |
674674

675675
For example, if you wanted the client to automatically attempt to re-send a request that failed
676-
(due to unreliable connections and servers, for example)
677-
you can add the [RetryPlugin](https://docs.php-http.org/en/latest/plugins/retry.html);
676+
(due to unreliable connections and servers, for example) you can add the [RetryPlugin](https://docs.php-http.org/en/latest/plugins/retry.html):
678677

679678
```php
680679
use ProgrammatorDev\Api\Api;
@@ -687,11 +686,11 @@ class YourApi extends Api
687686
// ...
688687

689688
// if a request fails, it will retry at least 3 times
690-
// priority is 12 to execute the plugin between the cache and logger plugins
689+
// priority is 20 to execute before the cache plugin
691690
// (check the above plugin order list for more information)
692691
$this->getClientBuilder()->addPlugin(
693-
plugin: new RetryPlugin(['retries' => 3])
694-
priority: 12
692+
plugin: new RetryPlugin(['retries' => 3]),
693+
priority: 20
695694
);
696695
}
697696
}
@@ -895,7 +894,7 @@ class YourApi extends Api
895894
}
896895
```
897896

898-
For the end user, it should look like this:
897+
When using the API, it should look like this:
899898

900899
```php
901900
$api = new YourApi([

0 commit comments

Comments
 (0)