/**
  * @param  Request $request
  * @param  int $id
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  *
  * @throws \RuntimeException
  */
 public function sliderAction(Request $request, $id)
 {
     // @todo сделать загрузку оригинальных картинок в /app/usr/SmartSliderModule
     /*
     $usrDir = $this->container->getParameter('kernel.root_dir') . '/usr';
     
     $sliderOriginalDir = '/SmartSliderModule';
     
     $usrDir .= $sliderOriginalDir;
     
     if (!is_dir($usrDir) and false === @mkdir($usrDir, 0777, true)) {
         throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $sliderOriginalDir, $usrDir));
     }
     */
     // -------------
     $sliderService = $this->get('smart_module.slider');
     $slider = $sliderService->getSlider($id);
     $slide = new Slide();
     $slide->setSlider($slider);
     $form = $this->createForm(SlideCreateFormType::class, $slide);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid() and null !== $form->get('file')->getData()) {
             $sliderService->save($form->getData());
             $this->get('session')->getFlashBag()->add('success', 'Слайд создан');
             return $this->redirect($this->generateUrl('smart_module.slider.admin_slider', ['id' => $slider->getId()]));
         }
     }
     $folderPath = null;
     foreach ($this->get('cms.node')->findByModule('Slider') as $node) {
         if ($node->getParam('slider_id') === (int) $id) {
             $folderPath = $this->get('cms.folder')->getUri($node);
             break;
         }
     }
     return $this->render('SliderModule:Admin:slider.html.twig', ['form' => $form->createView(), 'slider' => $slider, 'folderPath' => $folderPath, 'webPath' => $sliderService->getWebPath()]);
 }
 /**
  * @param Slide $slide
  *
  * @return $this
  */
 public function deleteSlide(Slide $slide)
 {
     unlink($this->webDir . '/' . $slide->getFileName());
     $this->em->remove($slide);
     $this->em->flush($slide);
     return $this;
 }