entityManager->getRepository(self::ENTITY)->findBy([], [ 'productLine' => 'ASC', 'model' => 'ASC', ]); $amd = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'AMD' && $cpu->isReceived()); $intel = array_filter($items, static fn (Cpu $cpu) => $cpu->getBrand()->getName() === 'Intel' && $cpu->isReceived()); $others = array_filter($items, static fn (Cpu $cpu) => ( ! in_array($cpu->getBrand()->getName(), ['AMD', 'Intel'], TRUE)) && $cpu->isReceived()); $notReceived = array_filter($items, static fn (CPU $cpu) => $cpu->isReceived() === FALSE); return $this->render($template, [ 'all' => [ 'not_acquired' => $notReceived, 'amd' => $amd, 'intel' => $intel, 'others' => $others, ], ]); } #[Route('/new', name: 'cpu_new', methods: ['GET', 'POST'])] public function new(Request $request): Response { return $this->itemCreate($request, 'cpu'); } #[Route('/{id}', name: 'cpu_show', methods: ['GET'])] public function show(Cpu $cpu): Response { return $this->itemView($cpu, 'cpu'); } #[Route('/{id}/edit', name: 'cpu_edit', methods: ['GET', 'POST'])] public function edit(Request $request, Cpu $cpu): Response { return $this->itemUpdate($request, $cpu, 'cpu'); } #[Route('/{id}', name: 'cpu_delete', methods: ['POST'])] public function delete(Request $request, Cpu $cpu): Response { return $this->deleteCSRF($request, $cpu); } /** * Moves a cpu to the previouslyOwned table */ #[Route(path: '/{id}/deacquire', name: 'cpu_deacquire', methods: ['POST'])] public function reacquireAction(Request $request, Cpu $cpu): RedirectResponse { return $this->itemDeacquire($request, $cpu, 'previously_owned_cpu_index'); } /** * Creates a form to move * * @param cpu $cpu The cpu entity */ private function createDeacquireForm(cpu $cpu): FormInterface { return $this->buildForm($cpu, 'cpu_deacquire'); } }