<?php
namespace App\Controller;
use App\Entity\Basketitem;
use App\Entity\Chilidocument;
use App\Entity\Whishlist;
use App\Service\ChiliServiceRest;
use App\Service\ChiliServiceSoap;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class BrowseController extends AbstractController
{
/**
* @Route("/Produkter", name="browse_level0")
*/
public function browselevel0(): Response
{
$folders = $this->getDoctrine()->getRepository(Chilidocument::class)->findBy(['mother' => config_chili_basefolder, 'is_folder' => true, 'is_active' => true],['sortorder' => 'asc']);
$files = $this->getDoctrine()->getRepository(Chilidocument::class)->findBy(['mother' => config_chili_basefolder, 'is_folder' => false, 'is_active' => true],['sortorder' => 'asc']);
$whishlist = $this->getDoctrine()->getRepository(Whishlist::class)->findBy(['user' => $this->getUser()]);
return $this->render('theme_' . config_theme . '/browse_levelX.html.twig', [
'theme' => config_theme,
'level' => '',
'files' => $files,
'folders' => $folders,
'whishlist' => $whishlist,
]);
}
/**
* @Route("/Produkter/{level1}", name="browse_level1")
*/
public function browselevel1($level1): Response
{
$folders = $this->getDoctrine()->getRepository(Chilidocument::class)->findBy(['mother' => config_chili_basefolder . '/' . $level1, 'is_folder' => true, 'is_active' => true],['sortorder' => 'asc']);
$files = $this->getDoctrine()->getRepository(Chilidocument::class)->findBy(['mother' => config_chili_basefolder . '/' . $level1, 'is_folder' => false, 'is_active' => true],['sortorder' => 'asc']);
$whishlist = $this->getDoctrine()->getRepository(Whishlist::class)->findBy(['user' => $this->getUser()]);
return $this->render('theme_' . config_theme . '/browse_levelX.html.twig', [
'theme' => config_theme,
'level' => $level1,
'files' => $files,
'folders' => $folders,
'whishlist' => $whishlist,
]);
}
/**
* @Route("/Produkter/{level1}/{level2}", name="browse_level2")
*/
public function browselevel2($level1,$level2): Response
{
$folders = $this->getDoctrine()->getRepository(Chilidocument::class)->findBy(['mother' => config_chili_basefolder . '/' . $level1 . '/' . $level2, 'is_folder' => true, 'is_active' => true],['sortorder' => 'asc']);
$files = $this->getDoctrine()->getRepository(Chilidocument::class)->findBy(['mother' => config_chili_basefolder . '/' . $level1 . '/' . $level2, 'is_folder' => false, 'is_active' => true],['sortorder' => 'asc']);
$whishlist = $this->getDoctrine()->getRepository(Whishlist::class)->findBy(['user' => $this->getUser()]);
return $this->render('theme_' . config_theme . '/browse_levelX.html.twig', [
'theme' => config_theme,
'level' => $level1 . '/' . $level2,
'files' => $files,
'folders' => $folders,
'whishlist' => $whishlist,
]);
}
/**
* @Route("/Produkt/{id}/frombasket", name="edit_product_from_basket")
*/
public function edit_product_from_basket($id, ChiliServiceSoap $chiliServiceSoap)
{
$basket_item = $this->getDoctrine()->getRepository(Basketitem::class)->findOneBy(['id' => $id]);
$id = $basket_item->getChilidocument()->getId();
$url = config_chili_server . '/CHILI/' . config_chili_environment . '/editor_html.aspx?doc=&apiKey=' . $chiliServiceSoap->GetApiKey() . '&fullWS=false&initialUserView=user&allowWorkspaceAdministration=false&maxImageQuality=highest';
return $this->render('theme_' . config_theme . '/editproduct.html.twig', [
'url' => $url,
'docxml' => $basket_item->getChiliXml(),
'docid' => $id,
]);
}
/**
* @Route("/Produkt/{id}", name="edit_product")
*/
public function edit_product($id, ChiliServiceSoap $chiliServiceSoap)
{
$url = config_chili_server . '/CHILI/' . config_chili_environment . '/editor_html.aspx?doc=&apiKey=' . $chiliServiceSoap->GetApiKey() . '&fullWS=false&initialUserView=user&allowWorkspaceAdministration=false&maxImageQuality=highest';
$chilidocument = $this->getDoctrine()->getRepository(Chilidocument::class)->find($id);
return $this->render('theme_' . config_theme . '/editproduct.html.twig', [
'url' => $url,
'docxml' => $chilidocument->getDocxml(),
'docid' => $id,
]);
}
}