From bcfa8e95e11e3c51cd3d4cae4b06a647e700e8b7 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Tue, 7 Jan 2020 12:57:58 -0700 Subject: [PATCH] Minor improvements to DirectoryController --- app/Controllers/DirectoryController.php | 10 +++++----- app/resources/views/index.twig | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Controllers/DirectoryController.php b/app/Controllers/DirectoryController.php index abbdb69..90d708c 100644 --- a/app/Controllers/DirectoryController.php +++ b/app/Controllers/DirectoryController.php @@ -62,7 +62,7 @@ class DirectoryController string $path = '.' ) { $path = realpath($this->container->get('base_path') . '/' . $path); - $search = $request->getQueryParams()['search'] ?? false; + $search = $request->getQueryParams()['search'] ?? null; try { $files = $files->in($path); @@ -77,8 +77,8 @@ class DirectoryController 'title' => $this->relativePath($path), 'breadcrumbs' => $this->breadcrumbs($path), 'is_root' => $this->isRoot($path), - 'search' => $search ?? null, - 'readme' => $search ? null : $this->readme($path), + 'readme' => $this->readme($path), + 'search' => $search, ]); } @@ -131,11 +131,11 @@ class DirectoryController } /** - * Return the README file in a path. + * Return the README file for a given path. * * @param string $path * - * @return \Symfony\Component\Finder\SplFileInfo + * @return \Symfony\Component\Finder\SplFileInfo|null */ protected function readme($path): SplFileInfo { diff --git a/app/resources/views/index.twig b/app/resources/views/index.twig index 69facf5..a695e35 100644 --- a/app/resources/views/index.twig +++ b/app/resources/views/index.twig @@ -31,7 +31,7 @@ {% endfor %} - {% if readme %} + {% if readme and not search %} {% include 'components/readme.twig' %} {% endif %}