| @@ 26-63 (lines=38) @@ | ||
| 23 | use Symfony\Component\HttpFoundation\Request; |
|
| 24 | use Symfony\Component\Routing\Annotation\Route; |
|
| 25 | ||
| 26 | class CssController extends AbstractController |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @Route("/%eccube_admin_route%/content/css", name="admin_content_css") |
|
| 30 | * @Template("@admin/Content/css.twig") |
|
| 31 | */ |
|
| 32 | public function index(Request $request) |
|
| 33 | { |
|
| 34 | $builder = $this->formFactory |
|
| 35 | ->createBuilder(FormType::class) |
|
| 36 | ->add('css', TextareaType::class, [ |
|
| 37 | 'required' => false |
|
| 38 | ]); |
|
| 39 | $form = $builder->getForm(); |
|
| 40 | ||
| 41 | $cssPath = $this->getParameter('eccube_html_dir').'/user_data/assets/css/customize.css'; |
|
| 42 | if (file_exists($cssPath) && is_writable($cssPath)) { |
|
| 43 | $form->get('css')->setData(file_get_contents($cssPath)); |
|
| 44 | } |
|
| 45 | ||
| 46 | $form->handleRequest($request); |
|
| 47 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 48 | $fs = new Filesystem(); |
|
| 49 | try { |
|
| 50 | $fs->dumpFile($cssPath, $form->get('css')->getData()); |
|
| 51 | $this->addSuccess('admin.common.save_complete', 'admin'); |
|
| 52 | return $this->redirectToRoute('admin_content_css'); |
|
| 53 | } catch (IOException $e) { |
|
| 54 | $message = trans('admin.common.save_error'); |
|
| 55 | $this->addError($message, 'admin'); |
|
| 56 | log_error($message, [$cssPath, $e]); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | return [ |
|
| 60 | 'form' => $form->createView() |
|
| 61 | ]; |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 25-63 (lines=39) @@ | ||
| 22 | use Symfony\Component\HttpFoundation\Request; |
|
| 23 | use Symfony\Component\Routing\Annotation\Route; |
|
| 24 | ||
| 25 | class JsController extends AbstractController |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * @Route("/%eccube_admin_route%/content/js", name="admin_content_js") |
|
| 29 | * @Template("@admin/Content/js.twig") |
|
| 30 | */ |
|
| 31 | public function index(Request $request) |
|
| 32 | { |
|
| 33 | $builder = $this->formFactory |
|
| 34 | ->createBuilder(FormType::class) |
|
| 35 | ->add('js', TextareaType::class, [ |
|
| 36 | 'required' => false |
|
| 37 | ]); |
|
| 38 | $form = $builder->getForm(); |
|
| 39 | $jsPath = $this->getParameter('eccube_html_dir').'/user_data/assets/js/customize.js'; |
|
| 40 | if (file_exists($jsPath) && is_writable($jsPath)) { |
|
| 41 | $form->get('js')->setData(file_get_contents($jsPath)); |
|
| 42 | } |
|
| 43 | ||
| 44 | $form->handleRequest($request); |
|
| 45 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 46 | ||
| 47 | $fs = new Filesystem(); |
|
| 48 | try { |
|
| 49 | $fs->dumpFile($jsPath, $form->get('js')->getData()); |
|
| 50 | $this->addSuccess('admin.common.save_complete', 'admin'); |
|
| 51 | return $this->redirectToRoute('admin_content_js'); |
|
| 52 | } catch (IOException $e) { |
|
| 53 | $message = trans('admin.common.save_error'); |
|
| 54 | $this->addError($message, 'admin'); |
|
| 55 | log_error($message, [$jsPath, $e]); |
|
| 56 | } |
|
| 57 | ||
| 58 | } |
|
| 59 | return [ |
|
| 60 | 'form' => $form->createView() |
|
| 61 | ]; |
|
| 62 | } |
|
| 63 | } |
|