<?php
namespace App\Controller\Pim;
use App\Enum\AssociationTypeEnum;
use App\Enum\AttributeEnum;
use App\Enum\EtimEnum;
use App\Enum\HistoricalEnum;
use App\Enum\PrivilegeEnum;
use App\Enum\RestrictionObjectTypeEnum;
use App\Enum\Workflow\UpdateTypeEnum;
use App\Services\Admin\ContextService;
use App\Services\Admin\CustomerService;
use App\Services\Admin\UserService;
use App\Services\Dam\FormatService;
use App\Services\Main\ExportService;
use App\Services\Main\StatusService;
use App\Services\Pim\AssociationService;
use App\Services\Pim\AttributeService;
use App\Services\Pim\AttributesGroupService;
use App\Services\Pim\CategoryService;
use App\Services\Pim\ChannelService;
use App\Services\Pim\FamilyService;
use App\Services\Pim\ProductService;
use App\Services\Pim\ReferentialService;
use App\Services\Util\JsonService;
use App\Services\Util\UtilService;
use App\Services\Workflow\WorkflowProcessService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class ProductController.
*
* @Route("/product", name="pim.product.")
*/
class ProductController extends AbstractController
{
/**
* @Route("/list", name="list", options={"expose" = true})
*
* @param Request $request
* @param ContextService $contextService
* @param CustomerService $customerService
* @param ProductService $productService
* @param AttributeService $attributeService
* @param AttributesGroupService $attributesGroupService
* @param ChannelService $channelService
* @param FamilyService $familyService
* @param StatusService $statusService
* @param UserService $userService
*
* @throws ExceptionInterface
*
* @return Response
*/
public function index(
Request $request,
ContextService $contextService,
CustomerService $customerService,
ProductService $productService,
AttributeService $attributeService,
AttributesGroupService $attributesGroupService,
ChannelService $channelService,
FamilyService $familyService,
StatusService $statusService,
UserService $userService,
UtilService $utilService,
ExportService $exportService
): Response {
if (!$userService->hasModule('pim') || !$userService->hasPrivilege(PrivilegeEnum::PRODUCTS_LIST)) {
$utilService->throwCustomException('global.errors.exceptions.pageNotFound');
}
$customer = $contextService->getCustomer();
$locale = $request->getLocale();
$listAttributesGroups = $attributesGroupService->getList();
$listAttributes = $attributeService->getList();
$AttributesTypes = array_column($listAttributes, 'type');
if (!in_array('id', $AttributesTypes)) {
$utilService->throwCustomException('global.errors.exceptions.noIdAttribute');
}
$listChannels = $channelService->getList();
if (empty($listChannels)) {
$utilService->throwCustomException('global.errors.exceptions.noChannelAvailable');
}
$defaultListAttributes = $channelService->getAttributesFromChannel($listChannels[0]);
$listColumns = $productService->getListColumns($this->getUser(), $locale, $listChannels, $defaultListAttributes);
$listRestrictions = $userService->getUserRestrictions();
$listLanguages = $customerService->getListLanguages([], true);
return $this->render('pim/product/list.html.twig', [
'listExports' => $exportService->getList(),
'MULTIPLE_VALUE' => ProductService::MULTIPLE_VALUE,
'fillingRate' => [
'values' => $customerService->getFillingRate($customer),
'limitations' => $customer->getCommercialLimitations(),
],
'listChannels' => [
'all' => $channelService->serializeListByColumn(
$listChannels,
'code'
),
'listable' => $channelService->serializeListByColumn(
$userService->filterListEntityWithRestrictions($listChannels, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_LIST, RestrictionObjectTypeEnum::CHANNEL),
'code'
),
],
'listLanguages' => [
'all' => array_column($listLanguages, 'code'),
'listable' => array_column($userService->filterListEntityWithRestrictions($listLanguages, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_LIST), 'code'),
],
'listFamilies' => $familyService->getFlatList(false),
'listStatus' => $statusService->getList(),
'listSerializedAttributesGroups' => $attributesGroupService->serializeListWithListAttributes($listAttributesGroups, 'code'),
'listColumns' => $listColumns,
'listColumnsCodes' => array_keys($listColumns),
'listAttributesGroups' => $listAttributesGroups,
'listAttributesNames' => $attributeService->getListAttributesNames($listAttributes, $locale),
'listAttributes' => [
'all' => $attributeService->serializeListByCode($listAttributes),
'listable' => $userService->filterListEntityWithRestrictions($listAttributes, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_LIST),
'typeTable' => array_column(
$attributeService->filterListByTypes($listAttributes, [AttributeEnum::TYPE_TABLE]),
'code'
),
'typeChoices' => $attributeService->serializeListAttributesChoices(
$attributeService->filterListByTypes(
$listAttributes,
[
AttributeEnum::TYPE_SELECT,
AttributeEnum::TYPE_MULTIPLE,
]
)
),
'typeId' => $attributeService->filterListByTypes($listAttributes, [AttributeEnum::TYPE_ID])[0] ?? null,
],
'defaultListColumns' => $productService->getDefaultListColumns($locale, $defaultListAttributes),
'listCompleteness' => $channelService->getCompleteness(),
]);
}
/**
* @Route(
* "/get-list/{json}",
* defaults={"json" = false},
* name="getList",
* options={"expose" = true}
* )
*
* @param Request $request
* @param ProductService $productService
* @param bool $json
*
* @return Response
*/
public function list(Request $request, ProductService $productService, bool $json = false): Response
{
$listParameters = $request->request->all();
$context = [
'channelCode' => $listParameters['channelCode'],
'languageCode' => $listParameters['languageCode'],
'listUniqId' => $listParameters['listUniqId'] ?? null,
'listId' => $listParameters['listId'] ?? null,
'listIdExcluded' => $listParameters['listIdExcluded'] ?? null,
'categoryCode' => $listParameters['categoryCode'] ?? null,
'listCategoriesId' => $listParameters['listCategoriesId'] ?? null,
'listCategoriesIdExcluded' => $listParameters['listCategoriesIdExcluded'] ?? null,
'fileCode' => $listParameters['fileCode'] ?? null,
'listFilters' => json_decode($listParameters['listFilters'] ?? '{}', true),
'listColumns' => (isset($listParameters['listColumns']))
? array_column($listParameters['listColumns'], 'data')
: null,
'sort' => $listParameters['sort'] ?? null,
'length' => $listParameters['length'],
'start' => $listParameters['start'],
];
return ($json)
? $this->json($productService->getListByContext($context))
: new Response(json_encode(
$productService->serializeForDatatable(
$productService->getListByContext($context),
[
'channelCode' => $listParameters['channelCode'],
'languageCode' => $listParameters['languageCode'],
'draw' => $listParameters['draw'],
'start' => $listParameters['start'],
'length' => $listParameters['length'],
'fastResult' => $context['listFilters']['fastResult'] ?? false,
]
)
), 200, ['Content-Type' => 'text/html']); //For some reaons it's faster return text/html than application/json and ajax/datable handle it correctly
}
/**
* @Route(
* "/edit/{id}/{channelCode}/{languageCode}/{origin}",
* defaults={"id" = null, "channelCode" = null, "languageCode" = null, "origin" = null},
* name="edit",
* methods={"GET", "POST"}
* )
*
* Usage examples :
* "/edit/null/catalog/fr?familyCode=animals" is a new product creation
* "/edit/[uuid]/catalog/fr" is a simple product edition
* "/edit/multiple/catalog/fr" is a multiple products edition, listIds are in session or sent in POST request
* "/edit/multiple/catalog/fr?categoryId=[uuid]" is a multiple products edition from products detail list
*
* @param TranslatorInterface $translator
* @param WorkflowProcessService $workflowProcessService
* @param ProductService $productService
* @param FamilyService $familyService
* @param CustomerService $customerService
* @param ChannelService $channelService
* @param CategoryService $categoryService
* @param StatusService $statusService
* @param AttributesGroupService $attributesGroupService
* @param AttributeService $attributeService
* @param ReferentialService $referentialService
* @param UserService $userService
* @param UtilService $utilService
* @param FormatService $formatService
* @param Request $request
* @param null|string $id
* @param null|string $channelCode
* @param null|string $languageCode
* @param null|string $origin
*
* @return Response
*/
public function edit(
TranslatorInterface $translator,
WorkflowProcessService $workflowProcessService,
ProductService $productService,
FamilyService $familyService,
CustomerService $customerService,
ChannelService $channelService,
CategoryService $categoryService,
StatusService $statusService,
AttributesGroupService $attributesGroupService,
AttributeService $attributeService,
ReferentialService $referentialService,
UserService $userService,
UtilService $utilService,
FormatService $formatService,
Request $request,
?string $id,
?string $channelCode,
?string $languageCode,
?string $origin = null
): Response {
if (!$userService->hasModule('pim') || !$userService->hasPrivilege(PrivilegeEnum::PRODUCTS_LIST)) {
$utilService->throwCustomException('global.errors.exceptions.pageNotFound');
}
$user = $this->getUser();
$categoryId = $request->query->get('categoryId');
$listChannels = $channelService->getList(['noRestriction' => true]);
if (null === $channelCode) {
$channel = $listChannels[0];
$channelCode = $channel['code'];
} else {
$channel = null;
foreach ($listChannels as $currentChannel) {
if ($currentChannel['code'] === $channelCode) {
$channel = $currentChannel;
break;
}
}
if (null === $channel) {
$channel = $listChannels[0];
}
}
$languageCode = (null === $languageCode || !in_array($languageCode, $channel['list_languages']))
? $channel['list_languages'][0]
: $languageCode;
$context = [
'channelCode' => $channelCode,
'languageCode' => $languageCode,
];
$listIds = null;
$session = new Session();
if (isset($categoryId)) {
$recursive = ('true' === $request->query->get('recursive'));
$categoryId = ('null' === $categoryId) ? null : $categoryId;
$categoryId = str_replace('products-list-', '', $categoryId);
$listFilters = $context;
if (null !== $request->cookies->get('productsFilters')) {
$cookieListFilters = json_decode($request->cookies->get('productsFilters'), true);
$listFilters = array_merge(
$listFilters,
[
'includeChildrenCategories' => $cookieListFilters['includeChildrenCategories'] ?? false,
'createdDateFrom' => $cookieListFilters['createdDateFrom'] ?? null,
'createdDateTo' => $cookieListFilters['createdDateTo'] ?? null,
'updatedDateFrom' => $cookieListFilters['updatedDateFrom'] ?? null,
'updatedDateTo' => $cookieListFilters['updatedDateTo'] ?? null,
'listStatusCodes' => $cookieListFilters['listStatusCodes'] ?? null,
'completeness' => $cookieListFilters['completeness'] ?? null,
'listFamilyCodes' => $cookieListFilters['listFamilyCodes'] ?? null,
'listAttributeFilters' => $cookieListFilters['listAttributes'] ?? null,
'search' => $cookieListFilters['search'] ?? null,
]
);
}
//TODO: ITDB-1495
$listIds = array_column($categoryService->getListProducts($categoryId, $recursive, $listFilters), 'product_id');
} elseif (null !== $request->request->get('listIds')) {
$listIds = json_decode($request->request->get('listIds') ?? '');
$session->set('listIds', $listIds);
return $this->json($listIds);
} elseif (null !== $session->get('listIds')) {
$listIds = $session->get('listIds');
}
$isMultipleEdition = (null !== $listIds && 'multiple' === $id);
$multipleEditionData = [];
if ($isMultipleEdition) {
$multipleEditionData = $productService->getMultipleEditionData($listIds);
$product = $multipleEditionData['commonValues'];
if (!$multipleEditionData['listProducts']) {
throw new NotFoundHttpException($translator->trans('categories.noProductFound', ['productsSingular' => mb_strtolower($translator->trans('products.singular'))]));
}
if (1 === count($multipleEditionData['listProducts']) && !count($multipleEditionData['listUniqIdsExcluded'])) {
$isMultipleEdition = false;
$id = $product['id'][0];
}
} elseif ('multiple' === $id) {
return $this->redirectToRoute('pim.product.list');
}
$isNewProduct = !$isMultipleEdition && ('null' === $id);
$familyCode = $request->query->get('familyCode');
if (!$isMultipleEdition) {
if ($isNewProduct) {
$product = $productService->getNewProductDefaultValues($familyCode);
} else {
$productResult = $productService->getProductById($id);
if ($productResult['error']) {
return $this->redirectToRoute('pim.product.list');
}
$product = $productResult['content'];
}
if (isset($product['id']) && $userService->hasPrivilege(PrivilegeEnum::COMPLETENESS)) {
$product['completeness'] = $productService->getCompleteness($product['id']);
}
}
$template = (null === $origin)
? 'pim/product/edit.html.twig'
: 'pim/product/edit/edit.html.twig';
$listAttributes = $attributeService->getList(['noRestriction' => true]);
$listAttributesByCodes = $attributeService->serializeListByCode($listAttributes);
$productSheet = $productService->getProductSheet(
$user->getCustomer(),
$product,
$channelCode,
$languageCode,
$listAttributesByCodes
);
$isEdition = (isset($product['id']));
$isProcessing = false;
$isProcessingDeletion = false;
if ($isEdition && !$isMultipleEdition) {
$userId = $user->getId();
$roleId = $user->getRole()->getId();
$context['listAssociations'] = $product['list_associations'] ?? [];
$isProcessing = $workflowProcessService->isObjectProcessing($id);
$product['workflow']['items'] = [];
if ($isProcessing) {
$isProcessingDeletion = $workflowProcessService->isObjectProcessing($id, [UpdateTypeEnum::DELETE]);
$product['workflow']['items'] = $productService->getProductWorkflowItems($product, $userId, $roleId, $context);
}
}
$listRestrictions = $userService->getUserRestrictions();
$defaultListAttributes = $channelService->getAttributesFromChannel($listChannels[0]);
$listFamilies = $familyService->getFlatList(false);
$listFamiliesById = $familyService->serializeListByColumn($listFamilies, 'id');
if (isset($product['family_id'])) {
$listFamiliesById[$product['family_id']]['family_has_attributes'] = $familyService->getById($product['family_id'])['content']['family_has_attributes'];
} elseif ($isNewProduct) {
$family = $familyService->getByCode($familyCode)['content'];
if (null === $family) {
return $this->redirectToRoute('pim.product.list');
}
$listFamiliesById[$family['id']]['family_has_attributes'] = $family['family_has_attributes'];
}
$listLanguages = $customerService->getListLanguages([], true);
$listablesAttributes = $attributeService->filterAllowedList($listAttributes, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_LIST);
return $this->render($template, [
'isEdition' => $isEdition || $isMultipleEdition,
'isMultipleEdition' => $isMultipleEdition,
'isProcessingDeletion' => $isProcessingDeletion,
'isProcessing' => $isProcessing,
'MULTIPLE_VALUE' => ProductService::MULTIPLE_VALUE,
'channelId' => $channel['id'],
'channelName' => $channel['name'],
'channelCode' => $channelCode,
'languageCode' => $languageCode,
'product' => $product,
'listMultipleEdition' => $multipleEditionData,
'listLanguages' => [
'all' => array_column($listLanguages, 'code'),
'listable' => array_column($userService->filterListEntityWithRestrictions($listLanguages, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_LIST), 'code'),
'editable' => array_column($userService->filterListEntityWithRestrictions($listLanguages, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_EDIT), 'code'),
],
'listChannels' => [
'all' => $channelService->serializeListByColumn(
$listChannels,
'code'
),
'listable' => $channelService->serializeListByColumn(
$userService->filterListEntityWithRestrictions($listChannels, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_LIST, RestrictionObjectTypeEnum::CHANNEL),
'code'
),
'editable' => $channelService->serializeListByColumn(
$userService->filterListEntityWithRestrictions($listChannels, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_EDIT, RestrictionObjectTypeEnum::CHANNEL),
'code'
),
],
'listAttributesGroups' => $attributesGroupService->getList(),
'listAttributes' => [
'all' => $listAttributesByCodes,
'listable' => $attributeService->serializeListByCode(
$listablesAttributes
),
'editable' => $attributeService->serializeListByCode(
$attributeService->filterAllowedList($listAttributes, $listRestrictions, RestrictionObjectTypeEnum::RESTRICTION_EDIT)
),
'declinable' => $attributeService->serializeListByCode(
$attributeService->filterDeclinableList($listablesAttributes)
),
'typeId' => $attributeService->filterListByTypes($listAttributes, [AttributeEnum::TYPE_ID])[0] ?? null,
'typeTable' => array_column(
$attributeService->filterListByTypes($listAttributes, [AttributeEnum::TYPE_TABLE]),
'code'
),
'typeChoices' => $attributeService->serializeListAttributesChoices(
$attributeService->filterListByTypes(
$listAttributes,
[
AttributeEnum::TYPE_SELECT,
AttributeEnum::TYPE_MULTIPLE,
]
)
),
],
'listFamilies' => $listFamiliesById,
'listFamiliesByCode' => $familyService->serializeListByColumn($listFamilies, 'code'),
'listReferentials' => $referentialService->getList(),
'listStatus' => $statusService->serializeListByColumn($statusService->getList(), 'code'),
'productSheet' => $productSheet,
'listAssociationsTypes' => AssociationTypeEnum::LIST_TYPES,
'listColumns' => $productService->getListColumns($user, $request->getLocale(), $listChannels, $defaultListAttributes),
'listFormats' => $formatService->getList(),
'listEtimRelease' => EtimEnum::LIST_ETIM_RELEASE,
]);
}
/**
* @Route("/get-common-categories", name="getCommonCategories")
*
* @param Request $request
* @param ProductService $productService
*
* @return Response
*/
public function getCommonCategories(Request $request, ProductService $productService): Response
{
return $this->json($productService->getCommonCategories($request->request->get('listIds')));
}
/**
* @Route("/completeness", name="completeness")
*
* @param ProductService $productService
* @param ChannelService $channelService
* @param UserService $userService
*
* @return Response
*/
public function completeness(
ProductService $productService,
ChannelService $channelService,
UserService $userService,
UtilService $utilService
): Response {
if (!$userService->hasModule('pim') || !$userService->hasPrivilege(PrivilegeEnum::COMPLETENESS)) {
$utilService->throwCustomException('global.errors.exceptions.pageNotFound');
}
return $this->render('main/completeness.html.twig', [
'listChannels' => $channelService->serializeListByColumn($channelService->getList(), 'code'),
'completeness' => $channelService->getCompleteness(),
]);
}
/**
* @Route("/get-categories/{id}", name="getListCategories")
*
* @param string $id
* @param ProductService $productService
*
* @return Response
*/
public function getListCategories(string $id, ProductService $productService): Response
{
return $this->json($productService->getListCategories($id));
}
/**
* @Route(
* "/save",
* name="save",
* methods={"POST"}
* )
*
* @param Request $request
* @param ContextService $contextService
* @param JsonService $jsonService
* @param ProductService $productService
* @param AttributeService $attributeService
* @param AssociationService $associationService
*
* @return Response
*/
public function save(
Request $request,
ContextService $contextService,
JsonService $jsonService,
ProductService $productService,
AttributeService $attributeService,
AssociationService $associationService
): Response {
$context = $request->request->get('context') ?? [];
$product = $jsonService->decode($request->request->get('product'));
$listsCustomChoices = $jsonService->decode($request->request->get('listsCustomChoices'));
if (count($listsCustomChoices) > 0) {
$attributeService->saveListsCustomChoices($listsCustomChoices);
}
$listDependenciesToDelete = $jsonService->decode($request->request->get('listDependenciesToDelete'));
if (count($listDependenciesToDelete) > 0 && isset($product['id'])) {
if (is_array($product['id'])) {
foreach ($product['id'] as $productId) {
$associationService->delete($listDependenciesToDelete, $productId, true);
}
} else {
$associationService->delete($listDependenciesToDelete, $product['id'], true);
}
}
$listProducts = $jsonService->decode($request->request->get('listProducts'));
if (count($listProducts) > 0) {
$listAssociationsToDelete = $jsonService->decode($request->request->get('listAssociationsToDelete'));
if (count($listAssociationsToDelete) > 0) {
foreach ($product['id'] as $productId) {
$associationService->delete($listAssociationsToDelete, $productId);
}
}
return $this->json(
$productService->saveList(
$listProducts,
$product,
$contextService->getCustomer(),
$context
)
);
}
$result = $productService->save(
$product,
$request->request->get('editType') ?? HistoricalEnum::TYPE_EDIT
);
if (!$result['error'] && isset($result['content']['product'])) {
$result['content']['product']['productSheet'] = $productService->getProductSheet(
$contextService->getCustomer(),
$result['content']['product'],
$context['channelCode'],
$context['languageCode'],
);
$result['content']['product']['completeness'] = $productService->getCompleteness($result['content']['product']['id']);
}
return $this->json($result);
}
/**
* @Route(
* "/duplicate",
* name="duplicate",
* methods={"POST"}
* )
*
* @param Request $request
* @param JsonService $jsonService
* @param ProductService $productService
*
* @return Response
*/
public function duplicate(Request $request, JsonService $jsonService, ProductService $productService): Response
{
return $this->json(
$productService->duplicate(
$request->request->get('productId'),
$request->request->get('uniqId'),
$request->request->get('originChannelId'),
$jsonService->decode($request->request->get('listChannelsCode'))
)
);
}
/**
* @Route(
* "/delete",
* name="delete",
* methods={"POST"}
* )
*
* @param Request $request
* @param ProductService $productService
*
* @return Response
*/
public function delete(Request $request, ProductService $productService): Response
{
$channelCode = $request->request->get('channel-code');
return $this->json(
$productService->delete(
$request->request->get('products-list'),
empty($channelCode) ? null : $channelCode
)
);
}
/**
* @Route("/id/{id}", name="getById")
*/
public function getById(
string $id,
ProductService $productService,
ContextService $contextService,
ChannelService $channelService,
AssociationService $associationService
): Response {
$channel = $channelService->getFirstChannel();
$channelCode = $channel['code'];
$languageCode = $channel['list_languages'][0];
$productResult = $productService->getProductById($id);
$differentByChannel = $associationService->isAssociationDifferentByChannel();
$listChannels = $channelService->getList(['noRestriction' => true]);
$productResult['content']['listAssociations'] = $associationService->serializeList(
$productResult['content']['list_associations'] ?? [],
[
'channelCode' => $channelCode,
'languageCode' => $languageCode,
],
$differentByChannel,
$listChannels
);
$productResult['content']['listDependencies'] = $associationService->serializeList(
$productResult['content']['list_dependencies'] ?? [],
[
'channelCode' => $channelCode,
'languageCode' => $languageCode,
],
$differentByChannel,
$listChannels
);
$productResult['content']['productSheet'] = $productService->getProductSheet(
$contextService->getCustomer(),
$productResult['content'],
$channelCode,
$languageCode,
);
$productResult['content']['completeness'] = $productService->getCompleteness($productResult['content']['id']);
return $this->json($productResult);
}
/**
* @Route(
* "/search/{string}/{channelCode}/{languageCode}/{codeAttributeImage}/{codeAttributeDescription}",
* name="search",
* options={"expose" = true}
* )
*
* @return JsonResponse
*/
public function search(
string $string,
string $channelCode,
string $languageCode,
string $codeAttributeImage,
string $codeAttributeDescription,
ProductService $productService
): Response {
$codeAttributeImage = ('null' === $codeAttributeImage) ? null : $codeAttributeImage;
$codeAttributeDescription = ('null' === $codeAttributeDescription) ? null : $codeAttributeDescription;
return $this->json(
$productService->search($string, $channelCode, $languageCode, $codeAttributeImage, $codeAttributeDescription)
);
}
/**
* @Route(
* "/list/id",
* name="getListUniqId"
* )
*/
public function getListUniqId(ProductService $productService): Response
{
return $this->json(
$productService->getListUniqId()
);
}
/**
* @Route(
* "/association/format-association-product",
* name="formatAssociationProduct",
* options={"expose" = true}
* )
*/
public function formatAssociationProduct(AssociationService $associationService, JsonService $jsonService, Request $request): Response
{
return $this->json(
$associationService->serializeAssociationDependencies(
$jsonService->decode($request->request->get('listAssociations')),
$jsonService->decode($request->request->get('listDependencies')),
$jsonService->decode($request->request->get('listChannels')),
$jsonService->decode($request->request->get('listChannelsAvailable')),
$jsonService->decode($request->request->get('context')),
'true' === $request->request->get('isMultipleEdition')
)
);
}
/**
* @Route(
* "/import-list-filter-file",
* name="importListFilterFile",
* methods={"POST"},
* options={"expose" = true}
* )
*/
public function importListFilterFile(Request $request, UtilService $utilService): Response
{
return $this->json(
$utilService->getExcelFileValues(
$request->files->get('import-list-filter-file'),
true
)
);
}
}