From 36bd562ab13ea288359281eaf3f56f6e967277a4 Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Sun, 8 Oct 2023 13:40:19 +0300 Subject: [PATCH 1/4] Add merge plan view action --- config/routes.php | 3 ++ src/Controller/ConfigController.php | 47 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/Controller/ConfigController.php diff --git a/config/routes.php b/config/routes.php index 7fd5827..3e87dbd 100644 --- a/config/routes.php +++ b/config/routes.php @@ -116,6 +116,9 @@ static function (ResponseFactoryInterface $responseFactory, ValidatorInterface $ Route::post('/curl/build') ->action([InspectController::class, 'buildCurl']) ->name('curl/build'), + Route::get('/config/merge-plan') + ->action([\Yiisoft\Yii\Debug\Api\Controller\ConfigController::class, 'read']) + ->name('config/merge-plan'), Group::create('/git') ->namePrefix('/git') ->routes( diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php new file mode 100644 index 0000000..40be194 --- /dev/null +++ b/src/Controller/ConfigController.php @@ -0,0 +1,47 @@ +run()->getResult(); + $mergePlanPath = substr($output, 0, strpos($output, "Xdebug: [Step Debug]") ?: -1); + + if (!file_exists($mergePlanPath)) { + throw new Exception( + sprintf( + 'Could not find composer.json by the path "%s".', + $mergePlanPath, + ) + ); + } + + $content = require $mergePlanPath; + + $result = [ + 'path' => $mergePlanPath, + 'data' => $content, + ]; + + return $this->responseFactory->createResponse($result); + } +} From 4e78d9169c1fbd7e71d063c7d1ad5ddc19d9034e Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 8 Oct 2023 10:40:36 +0000 Subject: [PATCH 2/4] Apply fixes from StyleCI --- src/Controller/ConfigController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php index 40be194..49f3c38 100644 --- a/src/Controller/ConfigController.php +++ b/src/Controller/ConfigController.php @@ -24,7 +24,7 @@ public function read(Aliases $aliases): ResponseInterface 'yii-config-merge-plan', ]); $output = $command->run()->getResult(); - $mergePlanPath = substr($output, 0, strpos($output, "Xdebug: [Step Debug]") ?: -1); + $mergePlanPath = substr($output, 0, strpos($output, 'Xdebug: [Step Debug]') ?: -1); if (!file_exists($mergePlanPath)) { throw new Exception( From 7aa5e74c7b6725d129a3c441d4aeb4afeb7b06b8 Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Sun, 8 Oct 2023 14:04:16 +0300 Subject: [PATCH 3/4] Remove absolute path --- src/Controller/ConfigController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php index 49f3c38..cfe1407 100644 --- a/src/Controller/ConfigController.php +++ b/src/Controller/ConfigController.php @@ -36,9 +36,10 @@ public function read(Aliases $aliases): ResponseInterface } $content = require $mergePlanPath; + $rootAlias = $aliases->get('@root'); $result = [ - 'path' => $mergePlanPath, + 'path' => substr($mergePlanPath, strlen($rootAlias) + 1), 'data' => $content, ]; From a70212d1436123ae221d3f7168dce97a5feb81f7 Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Sat, 14 Oct 2023 17:25:09 +0300 Subject: [PATCH 4/4] Add session inspector --- config/routes.php | 3 +++ src/Controller/InspectController.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/config/routes.php b/config/routes.php index 3e87dbd..d94078a 100644 --- a/config/routes.php +++ b/config/routes.php @@ -77,6 +77,9 @@ static function (ResponseFactoryInterface $responseFactory, ValidatorInterface $ Route::get('/events') ->action([InspectController::class, 'eventListeners']) ->name('events'), + Route::get('/session') + ->action([InspectController::class, 'session']) + ->name('session'), Route::get('/params') ->action([InspectController::class, 'params']) ->name('params'), diff --git a/src/Controller/InspectController.php b/src/Controller/InspectController.php index 7e0b73b..58a31a5 100644 --- a/src/Controller/InspectController.php +++ b/src/Controller/InspectController.php @@ -26,6 +26,7 @@ use Yiisoft\Router\CurrentRoute; use Yiisoft\Router\RouteCollectionInterface; use Yiisoft\Router\UrlMatcherInterface; +use Yiisoft\Session\SessionInterface; use Yiisoft\Translator\CategorySource; use Yiisoft\VarDumper\VarDumper; use Yiisoft\Yii\Debug\Api\Inspector\ApplicationState; @@ -402,6 +403,19 @@ public function eventListeners(ContainerInterface $container) ]); } + public function session(ContainerInterface $container): ResponseInterface + { + $session = $container->get(SessionInterface::class); + $data = $session->all(); + + return $this->responseFactory->createResponse([ + 'id' => $session->getId(), + 'name' => $session->getName(), + 'cookieParameters' => $session->getCookieParameters(), + 'data' => $data, + ]); + } + public function buildCurl( ServerRequestInterface $request, CollectorRepositoryInterface $collectorRepository