| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Writes frontend redirect-hit log records when a compatible log writer exists. |
| 9 |
*/ |
| 10 |
class ABJ_404_Solution_FrontendHitRecorder { |
| 11 |
|
| 12 |
/** @var mixed */ |
| 13 |
private $logsRepository; |
| 14 |
|
| 15 |
/** |
| 16 |
* @param mixed $logsRepository Object exposing logRedirectHit(). |
| 17 |
*/ |
| 18 |
function __construct($logsRepository) { |
| 19 |
$this->logsRepository = $logsRepository; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @param string $requestedUrl |
| 24 |
* @param string $action |
| 25 |
* @param string $matchReason |
| 26 |
* @param string|null $requestedUrlDetail |
| 27 |
* @param list<array{step: string, outcome: string, detail: string}>|null $pipelineTrace |
| 28 |
*/ |
| 29 |
function record(string $requestedUrl, string $action, string $matchReason, ?string $requestedUrlDetail = null, ?array $pipelineTrace = null): void { |
| 30 |
if (!is_object($this->logsRepository) || !is_callable(array($this->logsRepository, 'logRedirectHit'))) { |
| 31 |
return; |
| 32 |
} |
| 33 |
call_user_func(array($this->logsRepository, 'logRedirectHit'), ABJ_404_Solution_RedirectHitLogEntry::create($requestedUrl, $action, $matchReason, $requestedUrlDetail, $pipelineTrace)); |
| 34 |
} |
| 35 |
} |
| 36 |
|