public function findOr404(RequestConfiguration $configuration) { $request = $configuration->getRequest(); if ($request->attributes->has('_page')) { $page = $request->attributes->get('_page'); if ($page->getId() !== null) { return $page; } } return parent::findOr404($configuration); }
public function createNew() { // Get gallery item $galleryItem = parent::createNew(); $galleryId = $this->getRequest()->get('gallery_id'); $galleryRepository = $this->container->get('symedit.repository.image_gallery'); $gallery = $galleryRepository->find($galleryId); if (!$gallery) { throw $this->createNotFoundException('Gallery not found'); } $galleryItem->setGallery($gallery); return $galleryItem; }