<?php
namespace Import1CBundle\Controller\v3;
use Import1CBundle\Controller\BaseController;
use Import1CBundle\Helper\v3\RequestBiHelper;
use Import1CBundle\Service\v3\FactoryService;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use WebBundle\Entity\Factory;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
/**
* Class FactoryServiceController
* @Route("/factory/output")
* @package Import1CBundle\Controller\v3
*/
class FactoryServiceController extends BaseController
{
private FactoryService $factoryService;
public function __construct(FactoryService $factoryService)
{
$this->factoryService = $factoryService;
}
/**
* получить список фабрик на сайте, если БМ то выывести его список
* если редактор - то список всех фабрик
* @Route("/te", name="bi.3.factory.te")
*/
public function listFactoryAction(): Response
{
ini_set('memory_limit', '500M');
if (!$this->isGranted('ROLE_BI')) {
throw new AccessDeniedHttpException('Доступ запрещен');
}
$params = RequestBiHelper::factoryRequest([
'userRoleSign' => $this->userRoleSign,
'userRoleBm' => $this->userRoleBm,
'user' => $this->user,
]);
$data = $this->factoryService->listFactory($params);
return $this->render('@Import1C/factory-service/v3/list-factory.html.twig', $data);
}
/**
* открывает форму для просмотра данных фабрики
* @Route("/show/{id}", name="bi.3.factory.show")
* @ParamConverter(name="factory", class="WebBundle\Entity\Factory", options={"mapping":{"id":"id"}})
*/
public function showFactoryAction(Factory $factory): Response
{
if (!$this->isGranted('ROLE_BI')) {
throw new AccessDeniedHttpException('Доступ запрещен');
}
$params = RequestBiHelper::factoryRequest([
'userRoleSign' => $this->userRoleSign,
'userRoleBm' => $this->userRoleBm,
'userRoleDev' => $this->userRoleDev,
'factory' => $factory,
]);
$data = $this->factoryService->factoryShow($params);
return $this->render('@Import1C/factory-service/v3/show.html.twig', $data);
}
}