diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index c2381a3..40b0bf2 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -12,15 +12,15 @@ COPY ./docker-entrypoint.sh /usr/local/bin/ # https://github.com/fred-lab/Docker_Symfony/blob/master/docker/nodejs/docker-entrypoint.sh # Si jamais tu tombe là-dessus, merci Fred ! ;) RUN apk update \ - && chmod 777 /usr/local/bin/docker-entrypoint.sh \ - && echo -e '\033[0;31m' Change user permissions '\033[0m' \ - && cd /home/docker \ - && apk --no-cache add shadow && usermod -u $HOST_USER node && groupmod -g $HOST_USERGROUP node \ - && echo -e '\033[0;31m' Check Permissions for Workdir'\033[0m' $PWD \ - && ls -la \ - && apk del shadow \ - # Clean up apk cache folder and the virtuals folders - && rm -rf /var/cache/apk/* + && chmod 777 /usr/local/bin/docker-entrypoint.sh \ + && echo -e '\033[0;31m' Change user permissions '\033[0m' \ + && cd /home/docker \ + && apk --no-cache add shadow && usermod -u $HOST_USER node && groupmod -g $HOST_USERGROUP node \ + && echo -e '\033[0;31m' Check Permissions for Workdir'\033[0m' $PWD \ + && ls -la \ + && apk del shadow \ + # Clean up apk cache folder and the virtuals folders + && rm -rf /var/cache/apk/* ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index f010dd6..de423c7 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -57,6 +57,7 @@ public function findAllNotArchived(): array ->orderBy('u.email', 'ASC') ->getQuery() ->getResult(); + ; } public function findNotArchivedByEmail(string $email): ?User diff --git a/src/Service/Category/CategoryHelper.php b/src/Service/Category/CategoryHelper.php index 2d8fba8..8231dbc 100644 --- a/src/Service/Category/CategoryHelper.php +++ b/src/Service/Category/CategoryHelper.php @@ -8,6 +8,7 @@ use App\Exception\BadDataException; use App\Exception\NotFoundException; use App\Helper\ApiMessages; +use App\Repository\CategoryRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; @@ -15,6 +16,7 @@ final class CategoryHelper { public function __construct( private EntityManagerInterface $em, + private CategoryRepository $categoryRepository, ) { } @@ -26,9 +28,7 @@ public static function isEditRoute(Request $request): bool /** @throws NotFoundException */ public function editSlugParamExists(Request $request): ?Category { - return isset($request->get('_route_params')['slug']) - ? $this->em->getRepository(Category::class)->findOneBy(['slug' => $request->get('_route_params')['slug']]) - : null; + return $this->categoryRepository->findOneBySlug($request->get('slug', '')); } public static function generateEditSuccessMessage(Request $request): string @@ -50,10 +50,7 @@ public function validateRequestResource(Request $request, category $category): v public static function findNotArchivedFromProject(Project $project): array { - return array_map( - static fn (Category $category) => !$category->isArchived() ? $category : null, - $project->getCategories()->toArray() - ); + return array_filter($project->getCategories()->toArray(), fn (Category $category) => $category->isArchived()); } public static function categoryExists(?Category $category): bool diff --git a/src/Service/Project/ProjectHelper.php b/src/Service/Project/ProjectHelper.php index b8fdd02..0aedb7e 100644 --- a/src/Service/Project/ProjectHelper.php +++ b/src/Service/Project/ProjectHelper.php @@ -8,6 +8,7 @@ use App\Exception\BadDataException; use App\Exception\NotFoundException; use App\Helper\ApiMessages; +use App\Repository\ProjectRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; @@ -15,6 +16,7 @@ final class ProjectHelper { public function __construct( private EntityManagerInterface $em, + private ProjectRepository $projectRepository ) { } @@ -26,9 +28,7 @@ public static function isEditRoute(Request $request): bool /** @throws NotFoundException */ public function editSlugParamExists(Request $request): ?Project { - return isset($request->get('_route_params')['slug']) - ? $this->em->getRepository(Project::class)->findOneBy(['slug' => $request->get('_route_params')['slug']]) - : null; + return $this->projectRepository->findOneBySlug($request->get('slug', '')); } public static function generateEditSuccessMessage(Request $request): string diff --git a/src/Service/User/UserFinder.php b/src/Service/User/UserFinder.php index c503521..3fb3c74 100644 --- a/src/Service/User/UserFinder.php +++ b/src/Service/User/UserFinder.php @@ -33,9 +33,9 @@ public function getAll(): array return $this->userRepository->findAll(); } - public function getAllNotArchived(): array + public function getAllNotArchived() { - return $this->userRepository->findAllNotArchived(); + $this->userRepository->findAllNotArchived(); } /** @throws NotFoundException */ diff --git a/src/Service/User/UserHelper.php b/src/Service/User/UserHelper.php index ac29d88..7c2e10e 100644 --- a/src/Service/User/UserHelper.php +++ b/src/Service/User/UserHelper.php @@ -8,6 +8,7 @@ use App\Exception\BadDataException; use App\Exception\NotFoundException; use App\Helper\ApiMessages; +use App\Repository\UserRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; @@ -15,6 +16,7 @@ final class UserHelper { public function __construct( private EntityManagerInterface $em, + private UserRepository $userRepository, ) { } @@ -26,9 +28,7 @@ public static function isEditRoute(Request $request): bool /** @throws NotFoundException */ public function editSlugParamExists(Request $request): ?User { - return isset($request->get('_route_params')['slug']) - ? $this->em->getRepository(User::class)->findOneBy(['slug' => $request->get('_route_params')['slug']]) - : null; + return $this->userRepository->findOneBySlug($request->get('slug', '')); } public static function generateEditSuccessMessage(Request $request): string