You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+80-1Lines changed: 80 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -722,7 +722,7 @@ use ProgrammatorDev\Api\Builder\LoggerBuilder;
722
722
$this->getLoggerBuilder(): LoggerBuilder;
723
723
```
724
724
725
-
As an example:
725
+
As an example, if you wanted to save log into a file:
726
726
727
727
```php
728
728
use ProgrammatorDev\Api\Api;
@@ -763,6 +763,85 @@ $api->setClientBuilder(
763
763
);
764
764
```
765
765
766
+
### Configure Options
767
+
768
+
It is very common for APIs to offer different options (like language, timezone, etc.).
769
+
To simplify the process of configuring options, the [`OptionsResolver`](https://symfony.com/doc/current/components/options_resolver.html) is available.
770
+
It allows you to create a set of default options and their constraints such as required options, default values, allowed types, etc.
771
+
It then resolves the given options `array` against these default options to ensure it meets all the constraints.
772
+
773
+
For example, if an API has a language and timezone options:
774
+
775
+
```php
776
+
use ProgrammatorDev\Api\Api;
777
+
778
+
class YourApi extends Api
779
+
{
780
+
private array $options = [];
781
+
782
+
public function __construct(array $options = [])
783
+
{
784
+
parent::__construct();
785
+
786
+
$this->configureOptions($options);
787
+
$this->configureApi();
788
+
}
789
+
790
+
private function configureOptions(array $options): void
0 commit comments