RoutingDataCollector.php 959 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Profiler;
  8. use OC\AppFramework\Http\Request;
  9. use OCP\AppFramework\Http\Response;
  10. use OCP\DataCollector\AbstractDataCollector;
  11. class RoutingDataCollector extends AbstractDataCollector {
  12. private string $appName;
  13. private string $controllerName;
  14. private string $actionName;
  15. public function __construct(string $appName, string $controllerName, string $actionName) {
  16. $this->appName = $appName;
  17. $this->controllerName = $controllerName;
  18. $this->actionName = $actionName;
  19. }
  20. public function collect(Request $request, Response $response, ?\Throwable $exception = null): void {
  21. $this->data = [
  22. 'appName' => $this->appName,
  23. 'controllerName' => $this->controllerName,
  24. 'actionName' => $this->actionName,
  25. ];
  26. }
  27. public function getName(): string {
  28. return 'router';
  29. }
  30. }