@@ -13,7 +13,7 @@ A library for creating SDKs in PHP with support for:
13
13
- Event listeners;
14
14
- ...and more.
15
15
16
- All methods are public for full end user hackability 🔥.
16
+ All methods are public for full hackability 🔥.
17
17
18
18
## Requirements
19
19
@@ -527,7 +527,7 @@ Event listeners are then executed from the highest priority to the lowest:
527
527
528
528
``` php
529
529
use ProgrammatorDev\Api\Api;
530
- use ProgrammatorDev\Api\Event\PostRequestEvent ;
530
+ use ProgrammatorDev\Api\Event\ResponseContentsEvent ;
531
531
532
532
class YourApi extends Api
533
533
{
@@ -538,13 +538,13 @@ class YourApi extends Api
538
538
539
539
// executed last (lower priority)
540
540
$this->addResponseContentsListener(
541
- listener: function(PostRequestEvent $event) { ... },
541
+ listener: function(ResponseContentsEvent $event) { ... },
542
542
priority: 0
543
543
);
544
544
545
545
// executed first (higher priority)
546
546
$this->addResponseContentsListener(
547
- listener: function(PostRequestEvent $event) { ... },
547
+ listener: function(ResponseContentsEvent $event) { ... },
548
548
priority: 10
549
549
);
550
550
}
@@ -558,21 +558,21 @@ For that, you can use the `stopPropagation()` method:
558
558
559
559
``` php
560
560
use ProgrammatorDev\Api\Api;
561
- use ProgrammatorDev\Api\Event\PostRequestEvent ;
561
+ use ProgrammatorDev\Api\Event\ResponseContentsEvent ;
562
562
563
563
class YourApi extends Api
564
564
{
565
565
public function __construct()
566
566
{
567
- $this->addResponseContentsListener(function(PostRequestEvent $event) {
567
+ $this->addResponseContentsListener(function(ResponseContentsEvent $event) {
568
568
// stop propagation so future listeners of this event will not be called
569
569
$event->stopPropagation();
570
570
});
571
571
572
572
// this listener will not be called
573
- $this->addResponseContentsListener(function(PostRequestEvent $event) {
573
+ $this->addResponseContentsListener(function(ResponseContentsEvent $event) {
574
574
// ...
575
- });
575
+ });
576
576
}
577
577
}
578
578
```
@@ -849,11 +849,11 @@ class YourApi extends Api
849
849
{
850
850
parent::__construct();
851
851
852
- $this->configureOptions($options);
852
+ $this->options = $this-> configureOptions($options);
853
853
$this->configureApi();
854
854
}
855
855
856
- private function configureOptions(array $options): void
856
+ private function configureOptions(array $options): array
857
857
{
858
858
// set defaults values, if none were provided
859
859
$this->optionsResolver->setDefault('timezone', 'UTC');
@@ -867,8 +867,8 @@ class YourApi extends Api
867
867
$this->optionsResolver->setAllowedValues('timezone', \DateTimeZone::listIdentifiers());
868
868
$this->optionsResolver->setAllowedValues('language', ['en', 'pt']);
869
869
870
- // resolve and set to options property
871
- $this->options = $this->optionsResolver->resolve($options);
870
+ // return resolved options
871
+ return $this->optionsResolver->resolve($options);
872
872
}
873
873
874
874
private function configureApi(): void
0 commit comments