-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf07b2e
commit 19cc5cb
Showing
7 changed files
with
58 additions
and
36 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
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
32 changes: 32 additions & 0 deletions
32
Documentation/Events/_BeforeMatomoApiRequestEventListener.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace YourVendor\YourExtension\EventListener; | ||
|
||
use Brotkrueml\MatomoWidgets\Event\BeforeMatomoApiRequestEvent; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use YourVendor\YourExtension\Mapping\MatomoSiteMapper; | ||
|
||
final class BeforeMatomoApiRequestEventListener | ||
{ | ||
private MatomoSiteMapper $matomoSiteMapper; | ||
|
||
public function __construct(MatomoSiteMapper $matomoSiteMapper) | ||
{ | ||
$this->matomoSiteMapper = $matomoSiteMapper; | ||
} | ||
|
||
public function __invoke(BeforeMatomoApiRequestEvent $event): void | ||
{ | ||
$hostName = $this->getRequest()->getServerParams()['REMOTE_HOST']; | ||
if ($idSiteFromHostName = $this->matomoSiteMapper->getIdSiteFromHostName($hostName)) { | ||
$event->setIdSite($idSiteFromHostName); | ||
} | ||
} | ||
|
||
private function getRequest(): ServerRequestInterface | ||
{ | ||
return $GLOBALS['TYPO3_REQUEST']; | ||
} | ||
} |
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 @@ | ||
services: | ||
# Place here the default dependency injection configuration | ||
|
||
YourVendor\YourExtension\EventListener\BeforeMatomoApiRequestEventListener: | ||
tags: | ||
- name: event.listener | ||
identifier: 'your-extension/before-matomo-api-request' |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
|
||
use Symplify\EasyCodingStandard\Config\ECSConfig; | ||
|
||
return static function (ECSConfig $config): void { | ||
$config->import(__DIR__ . '/.Build/vendor/brotkrueml/coding-standards/config/common.php'); | ||
|
||
$config->paths([ | ||
__DIR__ . '/Documentation', | ||
]); | ||
}; |