elementTypeRepository = $elementTypeRepository; $this->valueRepository = $valueRepository; $this->pageOptionRepository = $pageOptionRepository; $this->exportTemplateOption = $exportTemplateOption; $this->exportsRepository = $exportsRepository; $this->elementMediaRepository = $elementMediaRepository; $this->elementCollect = $elementCollect; $this->collectElementValue = $collectElementValue; $this->pageOptionsQuery = $pageOptionsQuery; $this->templateQuery = $templateQuery; $this->mediaReadQuery = $mediaReadQuery; $this->optionReadQuery = $optionReadQuery; $this->variableReadQuery = $variableReadQuery; $this->generation = $generation; $this->mediaCollect = $mediaCollect; $this->entityManager = $entityManager; $this->logService = $logService; $this->export = null; $this->params = $params; } /** * {@inheritDoc} * @throws UnprocessableEntityMaestroException */ public function listGabValue(?int $idElement, ?int $pageId, int $exportId, ?int $pageDuplicateId, ?int $position, array $entityValue, ?array $flux = null) { $result = null; if ($exportId) { $export = $this->exportsRepository->findById($exportId); $idExportType = $export->getExportType(); if ($idExportType && $this->exportsRepository::EXPORT_TYPE[$idExportType]) { $exportType = $this->exportsRepository::EXPORT_TYPE[$export->getExportType()]; if ('CSV' === $exportType || 'JSON' === $exportType) { $result = $this->getListValueElement($export, $flux); } else { // $result = $this->getListGabValue($idElement, $pageId, $export, $exportType, $pageDuplicateId, $position); // Old way, keep it for instant $result = $this->getElementGabValuesBis($pageId, $idElement, $pageDuplicateId, $entityValue); } } } return $result; } /** * @param Exports $export * * @return array */ private function getListValueElement(Exports $export, ?array $flux): array { $result = []; if (!empty($export->getTemplates())) { foreach ($export->getTemplates() as $exportTemplate) { $elementType = $exportTemplate->getElementType(); if (isset($elementType)) { $elementTypeFieldsPIM = $elementType->getElementTypeFieldsPIM(); if (!empty($elementTypeFieldsPIM) && !empty($exportTemplate->getElementsPIM())) { $elements = $this->elementCollect->readMultiple($exportTemplate->getElementsPIM()); if (!empty($elements)) { foreach ($elements as $element) { $entityValue = $this->collectElementValue->readMultiple([$element['id']], $elementTypeFieldsPIM); $value = $this->prepareListValueElement($entityValue, $flux, $element["element_type_id"]); $result[] = ['id' => $element['id'], 'name' => $element['name'], 'value' => $value, 'version' => $element['element_version'], "typeId" => $element["element_type_id"], "typeName" => $element["element_type_name"]]; } } } } } } return $result; } /** * @param array $entityValue * * @return array */ private function prepareListValueElement(array $entityValue, ?array $flux, ?int $elementTypeId): array { $result = []; $fieldNoSort = []; $fields = []; if (!empty($flux)) { $fields = $flux[$elementTypeId]['fields']; } if ($entityValue['type'] === "success" && is_array($entityValue['data']) && !empty($entityValue['data'])) { foreach ($entityValue['data'] as $element) { foreach ($element['fields'] as $key => $data) { if ($data['fieldType'] === 'fieldset') { $index = false; if (!empty($fields)) { $filter = array_filter($fields, function ($field) use ($data) { return $field['protocol'] == $data['protocole']; }); if (!empty($filter)) { $index = array_keys($filter); $index = reset($index); $inputs = $fields[$index]['inputs']; $collections = []; if (isset($data['collections'])) { foreach ($data['collections'] as $collection) { $val = []; $valNoSort = []; foreach ($collection as $value) { if (!empty($inputs)) { $indexInput = false; $filter = array_filter($inputs, function ($input) use ($value) { return $input['protocol'] == $value['protocole']; }); if (!empty($filter)) { $indexInput = array_keys($filter); $indexInput = reset($indexInput); } if (is_int($indexInput)) { $val[$indexInput] = ['inputId' => $value['inputId'], 'name' => $value['name'], 'value' => $value['value'] ?? null, 'type' => $value['fieldType'], "protocole" => $value['protocole']]; } } if (!is_int($indexInput)) { $valNoSort[] = ['typeFieldId' => $key, 'name' => $data['name'], 'value' => $data['value'] ?? null, 'type' => $data['fieldType'], 'protocole' => $data['protocole']]; } } $val = array_merge(array_values($val), $valNoSort); $collections[] = $val; } } } if (is_int($index)) { $result[$index] = ['typeFieldId' => $key, 'name' => $data['name'], "values" => $collections, 'type' => "fieldset", "fieldsetId" => $data['fieldset']['id']]; } } if (!is_int($index)) { $collections = []; if (isset($data['collections'])) { foreach ($data['collections'] as $collection) { $val = []; foreach ($collection as $value) { $val[] = ['inputId' => $value['inputId'], 'name' => $value['name'], 'value' => $value['value'] ?? null, 'type' => $value['fieldType'], "protocole" => $value['protocole']]; } $collections[] = $val; } } $fieldNoSort[] = ['typeFieldId' => $key, 'name' => $data['name'], "values" => $collections, 'type' => "fieldset", "fieldsetId" => $data['fieldset']['id']]; } } elseif ($data['fieldType'] === 'productLink') { $elements = []; if (isset($data['elements'])) { foreach ($data['elements'] as $keyElement => $valueElement) { $val = []; if (isset($valueElement['inputs']) && !empty($valueElement['inputs'])) { foreach ($valueElement['inputs'] as $value) { $val[] = ['typeFieldId' => $value['inputId'], 'name' => $value['name'], 'value' => $value['value'] ?? null, 'type' => $value['fieldType'], "protocole" => $value['protocole']]; } $elements[] = ["id" => $keyElement, "name" => $valueElement['name'], 'version' => $valueElement['element_version'], "typeId" => $valueElement["element_type_id"], "typeName" => $valueElement["element_type_name"], "value" => $val]; } } } $index = false; if (!empty($fields)) { $filter = array_filter($fields, function ($field) use ($data) { return $field['protocol'] == $data['protocole']; }); if (!empty($filter)) { $index = array_keys($filter); $index = reset($index); } if (is_int($index)) { $result[$index] = ['typeFieldId' => $key, 'name' => $data['name'], "values" => $elements, 'type' => "productLink"]; } } if (!is_int($index)) { $fieldNoSort[] = ['typeFieldId' => $key, 'name' => $data['name'], "values" => $elements, 'type' => "productLink"]; } } else { $index = false; if (!empty($fields)) { $filter = array_filter($fields, function ($field) use ($data) { return $field['protocol'] == $data['protocole']; }); if (!empty($filter)) { $index = array_keys($filter); $index = reset($index); } if (is_int($index)) { $name = $data['name']; if ($fields[$index]['value']) { $name = $fields[$index]['value']; } $result[$index] = ['typeFieldId' => $key, 'name' => $name, 'value' => $data['value'] ?? null, 'type' => $data['fieldType'], 'protocole' => $data['protocole']]; } } if (!is_int($index)) { $fieldNoSort[] = ['typeFieldId' => $key, 'name' => $data['name'], 'value' => $data['value'] ?? null, 'type' => $data['fieldType'], 'protocole' => $data['protocole']]; } } } } } $result = array_merge(array_values($result), $fieldNoSort); return $result; } /** * {@inheritdoc} * @throws UnprocessableEntityMaestroException */ public function positionMedias(int $export_id, ?int $page_id, ?int $element_id, ?int $pageDuplicateId): array { $positionMedias = []; $medias = []; $forElement = false; $meds = []; if ($element_id !== null) { $forElement = true; } $repoElementMedia = $this->entityManager->getRepository(ElementMedia::class); if (isset($page_id) && $page_id > 0) { $pageOption = $this->pageOptionRepository->findByPageId($page_id); if (!empty($pageOption)) { $templateIdView = new CommonIdView( $pageOption->getTemplate()->getId() ); $templateRead = $this->templateQuery->read($templateIdView); if (!$templateRead) { throw new UnprocessableEntityMaestroException("No template found for id : $templateIdView->id"); } $positionMedias = $this->mediaReadQuery->listByTemplate($templateRead, $forElement); } if ($pageDuplicateId !== null) { // $export_media = $this->elementMediaRepository->findByPageAndVersion($page_id, $version); $export_media = $repoElementMedia->findBy(["flatplanPageId" => $page_id, "pageDuplicate" => $pageDuplicateId]); } else { $export_media = $this->elementMediaRepository->findByPage($page_id); } } else { if (isset($this->export) && !empty($this->export->getTemplates())) { $templateIdView = new CommonIdView( $this->export->getTemplates()->first()->getDefaultTemplate() ); $templateRead = $this->templateQuery->read($templateIdView); $positionMedias = $this->mediaReadQuery->listByTemplate($templateRead, $forElement); } if ($pageDuplicateId !== null) { $export_media = $repoElementMedia->findBy(["export" => $page_id, "version" => $pageDuplicateId]); } else { $export_media = $this->elementMediaRepository->findByExport($export_id); } } $mediaIds = ['medias' => [], "def" => "bd"]; $nbExportMedia = 0; $posDefaultMedia = 0; foreach ($export_media as $expMedia) { if (-1 !== $expMedia->getMediaId()) { $nbExportMedia++; $mediaIds['medias'][] = $expMedia->getMediaId(); } } $defaultMedias = []; if (count($positionMedias) > $nbExportMedia && !empty($element_id)) { $mediasAllPim = $this->mediaCollect->getByElement($element_id); $idsMedias["medias"] = array_map(function ($medPim) { return $medPim["id"]; }, $mediasAllPim["data"]); $defaultMedias = $this->mediaCollect->collectMediaByIds($idsMedias); } if (!empty($mediaIds['medias'])) { $meds = $this->mediaCollect->collectMediaByIds($mediaIds); } if (isset($positionMedias) && !empty($positionMedias)) { $position = 1; foreach ($positionMedias as $posMed) { $addDefault = true; if (!empty($posMed->variableProjectId)) { $id = -1; $width = 0.0; $height = 0.0; $positionX = 0.0; $positionY = 0.0; $rotate = 0.0; $mediaId = -1; $flipVertical = false; $flipHorizontal = false; $thumb = ""; $thumbPath = ""; $originalName = ""; $copyright = ""; $legend = ""; $dateValid = ""; $isExpired = false; $linkData = null; if (!empty($export_media)) { $search = array_filter($export_media, static function ($med) use ($posMed, $element_id, $export_id, $page_id) { return $med->getVariableProject() && $med->getVariableProject()->getId() === $posMed->variableProjectId && $med->getElementPIM() === $element_id && $med->getExport()->getId() === $export_id && $med->getFlatplanPageId() === $page_id; }); if (!empty($search) && !reset($search)->getDeletedAt()) { $id = reset($search)->getId() ?: -1; $width = reset($search)->getWidthMedia() ?: 0.0; $height = reset($search)->getHeightMedia() ?: 0.0; $positionX = reset($search)->getX() ?: 0.0; $positionY = reset($search)->getY() ?: 0.0; $mediaId = reset($search)->getMediaId() ?: -1; $rotate = reset($search)->getRotateMedia() ?: 0.0; $flipVertical = reset($search)->getFlipVertical() ?: false; $flipHorizontal = reset($search)->getFlipHorizontal() ?: false; $copyright = reset($search)->getCopyright(); $legend = reset($search)->getLegend(); $dateValid = !empty(reset($search)->getDateValid()) ? reset($search)->getDateValid()->format("Y-m-d") : null; $linkData = null !== reset($search)->getLinkData() ? json_decode(reset($search)->getLinkData(), true) : null; if (!empty($meds)) { $searchThumb = array_filter($meds, static function ($med) use ($search) { return $med['mediaId'] == reset($search)->getMediaId(); }); } else { $searchThumb = []; } if (!empty($searchThumb)) { //get the first index $addDefault = false; $searchThumb = reset($searchThumb); $crop = [ "height" => $height, "width" => $width, "x" => $positionX, "y" => $positionY, "rotate" => $rotate, "flipVertical" => $flipVertical, "flipHorizontal" => $flipHorizontal ]; if ($searchThumb['fileBd']) { $fileToGet = $searchThumb['fileBd']; $thumbFileToGet = $searchThumb['thumb']; $isBase64 = true; } else { $fileToGet = $searchThumb['fileBdPath']; $thumbFileToGet = $searchThumb['thumbPath']; $isBase64 = false; } if (empty($copyright)) { $copyright = $searchThumb['copyright']; } $dateValid = $searchThumb['dateValid']; $isExpired = $searchThumb['isExpired']; if (empty($legend)) { $legend = $searchThumb['legend']; } if ($width !== 0.0 || $height !== 0.0 || $positionX !== 0.0 || $positionY !== 0.0 || $rotate === true || $flipVertical === true || $flipHorizontal === true) { $thumb = $this->generation->cropMediaImage($thumbFileToGet, $crop, $fileToGet, $isBase64); } else { if ($searchThumb['thumbPath']) { $thumb = $searchThumb['thumbPath']; } else { $thumb = $searchThumb['thumb']; } } $thumbPath = $thumb ? '' : $searchThumb['thumbPath']; $originalName = $searchThumb['originalName']; } } } if ($addDefault && !empty($defaultMedias) && $posDefaultMedia < count($defaultMedias) && !$posMed->optional) { if ($defaultMedias[$posDefaultMedia]['fileBd']) { $fileToGet = $defaultMedias[$posDefaultMedia]['fileBd']; $thumbFileToGet = $defaultMedias[$posDefaultMedia]['thumb']; $isBase64 = true; } else { $fileToGet = $defaultMedias[$posDefaultMedia]['fileBdPath']; $thumbFileToGet = $defaultMedias[$posDefaultMedia]['thumbPath']; $isBase64 = false; } if (empty($copyright)) { $copyright = $defaultMedias[$posDefaultMedia]['copyright']; } $dateValid = $defaultMedias[$posDefaultMedia]['dateValid']; $isExpired = $defaultMedias[$posDefaultMedia]['isExpired']; if (empty($legend)) { $legend = $defaultMedias[$posDefaultMedia]['legend']; } if ($width !== 0.0 || $height !== 0.0 || $positionX !== 0.0 || $positionY !== 0.0 || $rotate === true || $flipVertical === true || $flipHorizontal === true) { $thumb = $this->generation->cropMediaImage($thumbFileToGet, $crop, $fileToGet, $isBase64); } else { if ($defaultMedias[$posDefaultMedia]['thumbPath']) { $thumb = $defaultMedias[$posDefaultMedia]['thumbPath']; } else { $thumb = $defaultMedias[$posDefaultMedia]['thumb']; } } $thumbPath = $thumb ? '' : $defaultMedias[$posDefaultMedia]['thumbPath']; $originalName = $defaultMedias[$posDefaultMedia]['originalName']; $mediaId = $defaultMedias[$posDefaultMedia]["mediaId"]; $posDefaultMedia++; } $medias[] = new ExportMediaView( $id, $posMed->position ?? $position, $mediaId, $posMed->name, $posMed->twigKey, $width, $height, $rotate, $positionX, $positionY, $flipVertical, $flipHorizontal, $originalName, $thumb, $thumbPath, $posMed->variableProjectId ?? null, $copyright, $legend, $dateValid, $posMed->height, $posMed->width, $isExpired, $linkData ); ++$position; } } } return $medias; } /** * {@inheritDoc * @throws UnprocessableEntityMaestroException */ public function templateOption(int $export_id, ?int $pageId, ?int $pageDuplicateId): array { $pageRepo = $this->entityManager->getRepository(Page::class); $page = $pageRepo->findOneBy([ "id" => $pageId ]); $templateId = $page->getOption()->getTemplate()->getId(); $options = []; $opt = []; if (isset($templateId)) { $templateIdView = new CommonIdView( $templateId ); $template = $this->templateQuery->read($templateIdView); if (!$template) { throw new UnprocessableEntityMaestroException("No template found for id : $templateIdView->id"); } $opt = $this->optionReadQuery->listByTemplate($template); } if (!empty($opt)) { if ($pageDuplicateId !== null) { $optionsBdd = $this->exportTemplateOption->findMultiplePageDuplicate($export_id, $pageId, count($opt), $pageDuplicateId); } else { $optionsBdd = $this->exportTemplateOption->findMultiple($export_id, $pageId, count($opt)); } foreach ($opt as $option) { if (!empty($option->variableProject)) { $value = ''; $id = null; if (!empty($optionsBdd)) { $optionId = $option->variableProject; $optionBdd = array_filter($optionsBdd, function ($optBdd) use ($optionId) { return $optBdd->getVariableProject() && $optBdd->getVariableProject()->getId() == $optionId; }); if (!empty($optionBdd)) { $value = reset($optionBdd)->getValue(); $id = reset($optionBdd)->getId(); } } $options[] = new TemplateOptionsView( $id, $option->name, $option->type, (int) $option->id, $value, $option->twigVar, $option->variableProject ); } } } return $options; } /** * {@inheritdoc} * @throws UnprocessableEntityMaestroException */ public function getElementsGabValues(PageElementsView $pageElementsView, ?Exports $export = null): array { $elementsGabValues = []; $elements = $pageElementsView->elements; $position = 0; if (!$export) { $elementIds = array_map(static function ($elem) { return $elem['id']; }, $elements); } else { $elementIds = $elements; $this->export = $export; } $entityValue = $this->readCollectElement($elementIds, $pageElementsView->id, $export); foreach ($elementIds as $elementId) { $elementsGabValues[] = $this->listGabValue($elementId, $pageElementsView->id, $pageElementsView->export, $pageElementsView->version, $position, $entityValue); $position++; } $elementsGabValues[] = $this->listGabValue(null, $pageElementsView->id, $pageElementsView->export, $pageElementsView->version, $position, []); return $elementsGabValues; } /** * {@inheritdoc} * @throws UnprocessableEntityMaestroException */ public function getOptionGabValue(PageDataGenerateView $data): array { $templateIdView = new CommonIdView( $data->template ); $template = $this->templateQuery->read($templateIdView); if (!$template) { throw new UnprocessableEntityMaestroException("No template found for id : $templateIdView->id"); } $option = $this->optionReadQuery->listByTemplate($template); $idExport = $data->export; $idPageFlatplan = $data->id; $newTabOption = array(); foreach ($option as $oneOption) { $idOption = $oneOption->id; $optionValue = $this->exportTemplateOption->findByExportOptionIdAndPageFlatplan($idExport, $idOption, $idPageFlatplan, $data->pageDuplicateId); if (!empty($optionValue)) { $oneOption->value = $optionValue->getValue(); } $newTabOption[] = $oneOption; } return $newTabOption; } /** * @param $val * * @return array|mixed */ private function prepareValueList($val) { if (is_string($val)) { $result = json_decode($val, true); if (empty($result) || !is_array($result)) { $result = []; } } else if (empty($val) || !is_array($val)) { $result = []; } else { $result = $val; } return $result; } /** * @param $valueProject * @param $valueFilter * @param $arrayData * @param $twigField * @param int|null $version * * @return array */ private function viewFieldset($valueProject, $valueFilter, $arrayData, $twigField, ?int $version): array { if (isset($valueProject) && !empty($valueProject)) { $col = []; foreach ($valueProject['collections'] as $element) { $view = []; foreach ($element as $input) { $find = false; $indexFilter = 0; $value = $input['value']; $editable = true; if ($version !== null) { $editable = isset($input["editable"]) ? $input['editable'] : false; } while ($indexFilter < count($valueFilter) && !$find) { $val = json_decode($valueFilter[$indexFilter]->getValue(), true); if (isset($val['collection']) && $val['collection'] == $input['collection'] && isset($val['templateInputId']) && $val['templateInputId'] == $input['templateInputId'] && isset($val['pimInputId']) && $val['pimInputId'] == $input['pimInputId']) { if (isset($val['valuePimId']) && (($val['valuePimId'] == $input['valuePimId']) || ($val['valuePimId'] == -1 && $input['valuePimId'] == null))) { $value = $val['value']; } } $indexFilter++; } if (array_key_exists('listValue', $input)) { $view[] = new InputListTemplateNameView( $input['name'], $value, $input['valuePimId'], $input['valueProjectId'], $input['fieldType'], $input['listValue'], $input['collection'], $input['templateInputId'], $input['pimInputId'], $input['twigVar'], $editable ); } else { $view[] = new InputTemplateNameView( $input['name'], $value, $input['valuePimId'], $input['valueProjectId'], $input['fieldType'], $input['collection'], $input['templateInputId'], $input['pimInputId'], $input['twigVar'], $editable ); } } $col[] = $view; } } else { $col = []; foreach ($arrayData as $key => $element) { if (is_array($twigField['inputs']) && !empty($twigField['inputs'])) { $view = []; foreach ($twigField['inputs'] as $input) { $field = $this->getInputValue($element, $input); $valuePro = null; $fieldVal = ''; $indexFilter = 0; $find = false; $editable = true; if ($version !== null) { $editable = $input->editable ?? false; } if (isset($field['value'])) { $fieldVal = $field['value']; } while ($indexFilter < count($valueFilter) && !$find) { $val = json_decode($valueFilter[$indexFilter]->getValue(), true); if (!empty($val) && isset($val['valuePimId']) && $field['inputId'] === $val['pimInputId'] && $key === $val['collection'] && $field['templateInputId'] === $val['templateInputId']) { $valuePro = $valueFilter[$indexFilter]->getId(); if (array_key_exists('listValue', $field)) { $fieldVal = $this->prepareValueList($val['value']); } else { $fieldVal = $val['value']; } $find = true; } $indexFilter++; } if (array_key_exists('listValue', $field)) { $view[] = new InputListTemplateNameView( $input->name, $fieldVal, $field['id'], $valuePro, $field['fieldType'], $field['listValue'], $key, $input->id, $field['inputId'], $input->variable, $editable ); } else { $view[] = new InputTemplateNameView( $input->name, $fieldVal, $field['id'], $valuePro, $field['fieldType'], $key, $input->id, $field['inputId'], $input->variable, $editable ); } } $col[] = $view; } } } return $col; } /** * @param $valueProject * @param $valueFilter * * @return array */ private function valueProductLink($valueProject, $valueFilter): array { array_shift($valueFilter); $col = []; if (isset($valueProject) && !empty($valueProject)) { $indexProduct = 0; while ($indexProduct < count($valueProject)) { if (isset($valueProject[$indexProduct]['value']) && !empty($valueProject[$indexProduct]['value'])) { $indexValue = 0; $values = $valueProject[$indexProduct]['value']; while ($indexValue < count($values)) { $find = false; $indexFilter = 0; while ($indexFilter < count($valueFilter) && !$find) { $val = json_decode($valueFilter[$indexFilter]->getValue(), true); if (isset($values[$indexValue]['valuePimId']) && $values[$indexValue]['valuePimId'] === $val['valuePimId']) { $valueProject[$indexProduct]['value'][$indexValue]['valueProjectId'] = $valueFilter[$indexFilter]->getId(); $valueProject[$indexProduct]['value'][$indexValue]['value'] = $val['value']; $valueProject[$indexProduct]['value'][$indexValue]['collection'] = $valueProject[$indexProduct]['id']; $find = true; } elseif (empty($values[$indexValue]['valuePimId']) && $val['valuePimId'] === -1 && $valueProject[$indexProduct]['id'] === $val['collection'] && $valueProject[$indexProduct]['value'][$indexValue]['templateInputId'] === $val['templateInputId']) { $valueProject[$indexProduct]['value'][$indexValue]['valueProjectId'] = $valueFilter[$indexFilter]->getId(); $valueProject[$indexProduct]['value'][$indexValue]['value'] = $val['value']; $valueProject[$indexProduct]['value'][$indexValue]['collection'] = $valueProject[$indexProduct]['id']; $find = true; } $indexFilter++; } $indexValue++; } } $indexProduct++; } $col = $valueProject; } return $col; } /** * @param $valueProject * @param $idElementLink * @param $element * @param $projectValues * @param $twigField * * @return array */ private function viewProductLink($idElementLink, $element, $twigField): array { $col = []; if (is_array($twigField['inputs']) && !empty($twigField['inputs'])) { $view = []; foreach ($twigField['inputs'] as $input) { $field = $this->getInputValue($element, $input); $valueProject = null; $fieldVal = $field['value'] ?? ''; if (array_key_exists('listValue', $field)) { $view[] = new InputListTemplateNameView( $input->name, $fieldVal, $field['id'], $valueProject, $field['fieldType'], $field['listValue'], $idElementLink, $input->id, $field['inputId'], $input->variable, true ); } else { $view[] = new InputTemplateNameView( $input->name, $field['value'], $field['id'], $valueProject, $field['fieldType'], $idElementLink, $input->id, $field['inputId'], $input->variable, true ); } } $col = $view; } return $col; } /** * @param array $element * @param $twigFieldInput * * @return array|mixed */ private function getInputValue(array $element, $twigFieldInput) { $fieldArea = [ 'value' => '', 'id' => -1, 'fieldType' => 'textarea', 'inputId' => -1, ]; if (isset($twigFieldInput->inputId)) { if (array_key_exists('inputs', $element)) { $element = $element['inputs']; } $input = array_filter($element, static function ($data) use ($twigFieldInput) { return +$data['inputId'] === $twigFieldInput->inputId; }); if (!empty($input)) { $field = reset($input); } else { $field = $fieldArea; } } else { $field = $fieldArea; } $field['templateInputId'] = $twigFieldInput->id; return $field; } /** * @param array $twigField * @param int $idElement * @param int $elemTypeFieldPIM * @param int|null $pageId * @param $export * * @return int */ private function createValue(array $twigField, int $idElement, int $elemTypeFieldPIM, ?int $pageId, $export): int { $valuePro = new Value(); $valuePro->setTemplateFieldId($twigField['id']); $valuePro->setPimElementId($idElement); $valuePro->setPimElementTypeFieldId($elemTypeFieldPIM); $valuePro->setFlatplanPageId($pageId); $valuePro->setExport($export); $valuePro = $this->valueRepository->create($valuePro); return $valuePro->getId(); } /** * @param $projectValues * @param $twigField * @param $idElement * @param $idExport * * @return array */ private function valueFilter($projectValues, $twigField, $idElement, $idExport): array { $valueProject = null; $idValueProject = 0; $valueFilter = array_values(array_filter($projectValues, static function ($v) use ($twigField, $idElement, $idExport) { return +$v->getTemplateFieldId() === +$twigField['id'] && $v->getPimElementId() === $idElement && $v->getExport()->getId() === $idExport; })); if (!empty($valueFilter)) { $idValueProject = reset($valueFilter)->getId(); $valueProject = json_decode(reset($valueFilter)->getValue(), true); } return ['idValueProject' => $idValueProject, 'valueProject' => $valueProject, 'valueFilter' => $valueFilter]; } /** * @param array $elementsGabValues * @param array $mediasFiles * * @return array */ public function addMediasFileName(array $elementsGabValues, array $mediasFiles): array { foreach ($elementsGabValues as $elementsGabValue) { if (isset($elementsGabValue->medias)) { foreach ($elementsGabValue->medias as $media) { $mediaId = $media->mediaId; $fileIndex = array_search($mediaId, array_column($mediasFiles, 'mediaId'), true); if (false !== $fileIndex && isset($mediasFiles[$fileIndex]['originalName'])) { if ($media->height > 0.0 && $media->width > 0.0) { $newMediaName = 'position-id-' . $media->exportMediaId . '_' . $mediasFiles[$fileIndex]['originalName']; $tmp = $mediasFiles[$fileIndex]; $tmp['originalName'] = $newMediaName; $mediasFiles[] = $tmp; } else { $newMediaName = $mediasFiles[$fileIndex]['originalName']; } $media->setFileName($newMediaName); } } } } return ['elementsGabValues' => $elementsGabValues, 'mediasFiles' => $mediasFiles]; } /* Unused method private function getTemplateFieldsByTemplate($templates_id) { $templateIdsView = new CommonTextView( $templates_id ); $templates = $this->templateQuery->listByTemplateIds($templateIdsView); $list = $this->variableReadQuery->listByTwigsTemplates($templates); return $list; } */ /** * {@inheritDoc} * @throws UnprocessableEntityMaestroException */ public function getElementGabValuesBis($page_id, $element_id, $pageDuplicate_id, $elementFieldPim) { $page = null; $element_name = "template_data"; $valueRepo = $this->entityManager->getRepository(Value::class); $layoutRepo = $this->entityManager->getRepository(Layout::class); $entityValue = []; $viewValues = []; if ($page_id) { $pageRepo = $this->entityManager->getRepository(Page::class); $pageDupliRepo = $this->entityManager->getRepository(PageDuplicate::class); $page = $pageRepo->find($page_id); if ($page) { if ($element_id) { if ($pageDuplicate_id) { $pageDuplicate = $pageDupliRepo->findOneBy([ "id" => $pageDuplicate_id ]); if (!empty($pageDuplicate)) { $pageElements = json_decode($pageDuplicate->getIdProducts(), true); } else { $pageElements = json_decode($page->getIdProducts(), true); } } else { $pageElements = json_decode($page->getIdProducts(), true); } $pageElement = array_filter($pageElements, function ($elem) use ($element_id) { return $elem['id'] == $element_id; }); if (!empty($pageElement)) { $element_name = reset($pageElement)['name']; } } $template = $page->getOption()->getTemplate(); $this->export = $page->getCdf()->getExport(); $medias = $this->positionMedias($this->export->getId(), $page_id, $element_id, $pageDuplicate_id); $projectId = $page->getCdf()->getExport()->getProject()->getId(); } else { throw new UnprocessableEntityMaestroException("Page $page_id not found", 'page', 'find'); } } else { $templateRepo = $this->entityManager->getRepository(Template::class); $exportId = $this->export->getId(); $elementTypeTemplate = $this->export->getTemplates()->first(); $templateId = $elementTypeTemplate->getDefaultTemplate(); // $elementTypeTemplate->getTemplates()[0]["id"]; $template = $templateRepo->find($templateId); // @TODO: See if it's usefull with a version where media s will be assigned in template configuration instead of a page $medias = $this->positionMedias($exportId, $page_id, $element_id, $pageDuplicate_id); $projectId = $this->export->getProject()->getId(); } $useProduct = $this->export && $this->export->getProject() ? $this->export->getProject()->getProductsImport() : null; $variables = $template->getTwig()->getVariables()->filter(function ($var) use ($element_id) { return $var->getForElement() == (bool) $element_id; }); if ($page_id && empty($element_id)) { $options = $this->templateOption($this->export->getId(), $page_id, $pageDuplicate_id); } else { $options = []; } $existingIndex = !empty($element_id) && isset($elementFieldPim[$element_id]); if ($existingIndex && isset($elementFieldPim[$element_id]['elementType'])) { $elementTypePim = $elementFieldPim[$element_id]["elementType"]; $elementType = $this->elementTypeRepository->findElementTypeByIdProject($elementTypePim, $projectId); } else { $elementType = $this->elementTypeRepository->findNoElementTypeByIdProject($projectId); } if ($existingIndex && isset($elementFieldPim[$element_id]['fields'])) { $entityValue = $elementFieldPim[$element_id]['fields']; } $utils = []; if ($existingIndex && $elementFieldPim[$element_id]) { $utils = [ "tags" => $elementFieldPim[$element_id]['tags'], "elementType" => $elementFieldPim[$element_id]['elementTypeName'], "element" => $elementFieldPim[$element_id]['element'] ]; } if ((!$variables->isEmpty() && null !== $page && !empty($page->getOption()->getTemplate())) || (null === $page && isset($this->export))) { $criteriaObj = new Criteria(); $criteriaObj->orderBy(["position" => Criteria::ASC]); $variables = $variables->matching($criteriaObj); foreach ($variables as $variable) { if ($variable->getDeletedAt() === null && !empty($variable->getVariableProject())) { $result = null; $name = $variable->getName(); $type = !empty($variable->getFieldType()) ? $variable->getFieldType() : "textarea"; $value = $type === "list" || $type === "list multiple" ? [] : null; $valueProject = null; $idCollection = 0; $view = [ "valuePimId" => null, "fieldId" => null, "typeFieldId" => null, "listValue" => json_decode($variable->getListValue(), true) ]; $layout = $layoutRepo->findOneBy([ // element_type_template_configuration "variableProject" => $variable->getVariableProject()->getId(), // int template_field_id "elementType" => $elementType->getId(), // ElementType project_element_type "deletedAt" => null, ]); //value page duplicate PROJECT if (!empty($pageDuplicate_id)) { $result = $valueRepo->findOneBy([ "variableProject" => $variable->getVariableProject()->getId(), "pimElementId" => $element_id, "flatplanPageId" => $page_id, "pageDuplicate" => $pageDuplicate_id, "deletedAt" => null, "collection" => null, ]); } //value Master PROJECT if (empty($result)) { $result = $valueRepo->findOneBy([ "variableProject" => $variable->getVariableProject()->getId(), "pimElementId" => $element_id, "flatplanPageId" => $page_id, "pageDuplicate" => null, "deletedAt" => null, "collection" => null, ]); } if (!empty($result)) { $value = $result->getValue(); $valueProject = $result->getId(); if ($type === "fieldset" || $type === "productLink") { $value = json_decode($value, true); if (isset($value['collections']) && !empty($value['collections'])) { $idCollection = $value['idLastCol']; $collections = $value['collections']; $value = ["collections" => [], "fieldset" => []]; $layoutInputs = []; if (!empty($layout)) { $layoutInputs = $layout->getInputs(); } foreach ($collections as $key => $collection) { $col = !empty($collection) && isset(reset($collection)['collection']) ? reset($collection)['collection'] : $key + 1; $value['collections'][] = $this->valueFieldsetPim($collection, $layoutInputs, $variable->getInputs(), $pageDuplicate_id, $valueRepo, $variable, $col, $element_id, $page_id, "collections"); } } else if (isset($value['products']) && !empty($value['products'])) { $collections = $value['products']; $value = ["products" => [], "elements" => []]; $layoutInputs = []; if (!empty($layout)) { $layoutInputs = $layout->getInputs(); } foreach ($collections as $key => $collection) { $value['products'][] = ['id' => $collection['id'], 'name' => $collection['name'], "value" => $this->valueFieldsetPim($collection['value'], $layoutInputs, $variable->getInputs(), $pageDuplicate_id, $valueRepo, $variable, $collection['id'], $element_id, $page_id, "collections")]; } } else { $value = ["collections" => [], "products" => []]; } } } if ($type === "fieldset") { if (empty($value)) { $value["collections"] = []; } $value["fieldset"] = []; if (!$variable->getInputs()->isEmpty()) { foreach ($variable->getInputs() as $input) { if ($input->getDeletedAt() === null && !empty($input->getVariableProject())) { $value["fieldset"][] = [ "name" => $input->getVariableProject()->getName(), "value" => null, "valuePimId" => null, "valueProjectId" => null, "fieldType" => !empty($input->getFieldType()) ? $input->getFieldType() : "textarea", "listValue" => !empty($input->getListValue()) ? (is_array($input->getListValue()) ? $input->getListValue() : json_decode($input->getListValue(), true)) : [], "collection" => $idCollection, "variableProjectId" => $input->getVariableProject()->getId(), "pimInputId" => null, "twigVar" => $input->getVariableName(), "editable" => true ]; } } } } //value PIM if ($useProduct && !empty($layout) && !empty($layout->getElementTypeFieldId()) && isset($entityValue[$layout->getElementTypeFieldId()])) { if (!empty($entityValue)) { $type = $entityValue[$layout->getElementTypeFieldId()]["fieldType"]; $result = $entityValue[$layout->getElementTypeFieldId()]; $view = [ "valuePimId" => $result["id"] ?? null, "fieldId" => isset($result['fieldId']) ? $result["fieldId"] : null, "typeFieldId" => isset($result['typeFieldId']) ? $result["typeFieldId"] : null, "listValue" => isset($result['listValue']) ? $result["listValue"] : [], "multiple" => isset($result['multiple']) ? $result["multiple"] : false ]; } if (empty($valueProject)) { $value = $result['value'] ?? null; if ($result['fieldType'] === "fieldset") { $value = []; if (isset($result['collections']) && !empty($result['collections'])) { foreach ($result['collections'] as $key => $collection) { $value['collections'][] = $this->valueFieldsetPim($collection, $layout->getInputs(), $variable->getInputs(), $pageDuplicate_id, $valueRepo, $variable, $key, $element_id, $page_id, "collections"); $idCollection = $key + 1; } } else { $value["collections"] = []; } } else if ($result['fieldType'] === "productLink") { if (isset($result['elements']) && !empty($result['elements'])) { foreach ($result['elements'] as $key => $element) { $value['products'][] = ['id' => $key, 'name' => $element['name'], 'value' => $this->valueFieldsetPim($element['inputs'], $layout->getInputs(), $variable->getInputs(), $pageDuplicate_id, $valueRepo, $variable, $key, $element_id, $page_id, "collections")]; } } else { $value['products'] = []; } } } if (isset($result['fieldset']) && !empty($result['fieldset'])) { $value['fieldset'] = $this->valueFieldsetPim($result['fieldset']['inputs'], $layout->getInputs(), $variable->getInputs(), $pageDuplicate_id, $valueRepo, $variable, $idCollection, $element_id, $page_id, "fieldset"); } else if (isset($result['listProducts']) && !empty($result['listProducts'])) { $value['elements'] = []; foreach ($result['listProducts'] as $key => $element) { $value['elements'][] = ['id' => $key, 'name' => $element['name']]; } } } switch ($type) { case 'productLink': $viewValues[] = new ElementFieldProductLinkTemplateNameView( !empty($layout) ? $layout->getName() : $variable->getVariableProject()->getName(), !empty($value) ? $value['products'] : [], !empty($valueProject) ? $valueProject : 0, $type, null, !empty($layout) ? $layout->getElementTypeFieldId() : null, $variable->getVariableProject()->getId(), $variable->getId(), !empty($layout) ? $layout->getId() : null, $element_id, !empty($value) ? $value['elements'] : [], $variable->getTwigVar(), $pageDuplicate_id && !empty($layout) ? $layout->getEditable() : true ); break; case 'fieldset': $viewValues[] = new ElementFieldSetTemplateNameView( !empty($layout) ? $layout->getName() : $variable->getVariableProject()->getName(), $value['collections'], // les values des input $valueProject, $type, null, !empty($layout) ? $layout->getElementTypeFieldId() : null, $variable->getVariableProject()->getId(), $variable->getId(), !empty($layout) ? $layout->getId() : null, $value["fieldset"], // $fieldset pour ajouter des collections $element_id, $variable->getTwigVar(), $pageDuplicate_id && !empty($layout) ? $layout->getEditable() : true ); break; case 'list': case 'list multiple': $viewValues[] = new ElementFieldsListTemplateNameView( !empty($layout) ? $layout->getName() : $variable->getVariableProject()->getName(), is_array($value) ? $value : json_decode($value, true), $view['valuePimId'], $valueProject, $type, $view['fieldId'], $view['typeFieldId'], $variable->getVariableProject()->getId(), $variable->getId(), !empty($layout) ? $layout->getId() : null, $view['listValue'], $element_id, $variable->getTwigVar(), $pageDuplicate_id && !empty($layout) ? $layout->getEditable() : true ); break; default: $viewValues[] = new ElementFieldsTemplateNameView( !empty($layout) ? $layout->getName() : $variable->getVariableProject()->getName(), $value, $view['valuePimId'], $valueProject, $type, $view['fieldId'], $view['typeFieldId'], $variable->getVariableProject()->getId(), $variable->getId(), !empty($layout) ? $layout->getId() : null, $element_id, $variable->getTwigVar(), $pageDuplicate_id && !empty($layout) ? $layout->getEditable() : true, isset($view['multiple']) ? $view['multiple'] : false ); break; } } } } return new ElementValuesView($element_id, $element_name, $viewValues, $medias, $options, $utils); } /** * @param $pageDuplicateId * @param $valueRepo * @param $inputId * @param $collection * @param $templateFieldId * @param $elementId * @param $pageId * * @return null */ private function valueInput( $pageDuplicateId, $valueRepo, $variableProjectId, $collection, $templateInputId, $elementId, $pageId ) { $result = null; $valueInput = null; if (!empty($pageDuplicateId)) { $valueInput = $valueRepo->findOneBy([ "inputProject" => $templateInputId, "pimElementId" => $elementId, "flatplanPageId" => $pageId, "pageDuplicate" => $pageDuplicateId, "collection" => $collection, "variableProject" => $variableProjectId, "deletedAt" => null ]); } if ($valueInput === null || empty($valueInput)) { $valueInput = $valueRepo->findOneBy([ "inputProject" => $templateInputId, "pimElementId" => $elementId, "flatplanPageId" => $pageId, "pageDuplicate" => null, "collection" => $collection, "variableProject" => $variableProjectId, "deletedAt" => null ]); } if (!empty($valueInput)) { $result = $valueInput; } return $result; } /** * @param $fieldset * @param $layoutInputs * @param $inputs * @param $pageDuplicateId * @param $valueRepo * @param $variable * @param $collection * @param $elementId * @param $pageId * @param $role * * @return array */ private function valueFieldsetPim($fieldset, $layoutInputs, $inputs, $pageDuplicateId, $valueRepo, $variable, $collection, $elementId, $pageId, $role): array { $result = []; $criteriaObj = new Criteria(); $criteriaObj->orderBy(["position" => Criteria::ASC]); $inputs = $inputs->matching($criteriaObj); foreach ($inputs as $input) { $indexInput = null; if ($input->getDeletedAt() == null && !empty($input->getVariableProject())) { $val = $this->valueInput($pageDuplicateId, $valueRepo, $variable->getVariableProject()->getId(), $collection, $input->getVariableProject()->getId(), $elementId, $pageId); $inp = [ "name" => $input->getVariableProject()->getName(), "value" => !empty($val) ? $val->getValue() : "", "valuePimId" => null, "valueProjectId" => !empty($val) ? $val->getId() : null, "fieldType" => !empty($input->getFieldType()) ? $input->getFieldType() : "textarea", "listValue" => !empty($input->getListValue()) ? (is_array($input->getListValue()) ? $input->getListValue() : json_decode($input->getListValue(), true)) : [], "collection" => $collection, "variableProjectId" => $input->getVariableProject()->getId(), "pimInputId" => null, "twigVar" => $input->getVariableName(), "editable" => true ]; $layoutFilter = array_filter($layoutInputs, static function ($layoutInp) use ($input) { return $input->getVariableProject()->getId() === (int) $layoutInp['variableProjectId']; }); $filterInput = null; if (!empty($layoutFilter)) { if (isset(reset($fieldset)['variableProjectId'])) { $filterInput = array_filter($fieldset, static function () use ($inp, $layoutFilter) { if (!isset($inp['variableProjectId'])) { return false; } return (int) reset($layoutFilter)['variableProjectId'] === (int) $inp['variableProjectId']; }); $indexInput = array_search($input->getVariableProject()->getId(), array_column($filterInput, "variableProjectId")); if (!empty($filterInput) && $indexInput >= 0) { $filterInput = $filterInput[$indexInput]; } } else if (isset(reset($fieldset)['inputId'])) { $filterInput = array_filter($fieldset, static function ($oneFieldset) use ($layoutFilter) { if (!isset($oneFieldset['inputId'])) { return false; } return (int) reset($layoutFilter)['inputId'] === (int) $oneFieldset['inputId']; }); $filterInput = reset($filterInput); } else { if (!empty(reset($layoutFilter)['inputId'])) { $filterInput = [ "id" => null, "fieldType" => $fieldset[reset($layoutFilter)['inputId']]['fieldType'], "listValue" => $fieldset[reset($layoutFilter)['inputId']]['listValue'] ?? [], "value" => $fieldset[reset($layoutFilter)['inputId']]['value'], ]; } } if (!empty($filterInput)) { $inp = [ "name" => $input->getVariableProject()->getName(), "value" => !empty($val) ? $val->getValue() : $filterInput["value"], "valuePimId" => $filterInput["id"] ?? null, "valueProjectId" => !empty($val) ? $val->getId() : null, "fieldType" => isset($filterInput["fieldType"]) ? $filterInput["fieldType"] : (!empty($input->getFieldType()) ? $input->getFieldType() : "textarea"), "listValue" => $filterInput["listValue"] ?? [], "collection" => $collection ?? 0, "variableProjectId" => $input->getVariableProject()->getId(), "pimInputId" => reset($layoutFilter)['inputId'], "twigVar" => $input->getVariableName(), "editable" => !empty($pageDuplicateId) ? reset($layoutFilter)['editable'] : true, "multiple" => isset(reset($filterInput)["multiple"]) ? reset($filterInput)["multiple"] : "zeubi B" ]; } } if ($inp['fieldType'] === "list" || $inp['fieldType'] === "list multiple") { $result[] = new InputListTemplateNameView( $inp['name'], $role === "collections" ? (is_string($inp['value']) && $inp['fieldType'] === "list multiple" ? json_decode($inp['value'], true) : $inp['value']) : [], $inp['valuePimId'], $role === "collections" ? $inp['valueProjectId'] : null, $inp['fieldType'], is_array($inp['listValue']) ? $inp['listValue'] : json_decode($inp['listValue'], true), $role === "collections" ? $inp['collection'] : $collection, $inp['variableProjectId'], $inp['pimInputId'], $inp['twigVar'], $inp['editable'] ); } else { $result[] = new InputTemplateNameView( $inp['name'], $role === "collections" ? $inp['value'] : "", $inp['valuePimId'], $role === "collections" ? $inp['valueProjectId'] : null, $inp['fieldType'], $role === "collections" ? $inp['collection'] : $collection, $inp['variableProjectId'], $inp['pimInputId'], $inp['twigVar'], $inp['editable'], isset($inp["multiple"]) ? $inp["multiple"] : false ); } } } return $result; } /** * {@inheritDoc} * @throws InternalServerErrorMaestroException */ public function readCollectElement(array $elementIds, ?int $pageId, ?Exports $export = null, ?bool $allFields = false) { $this->logService->setLog('Start readCollectElement function'); if ($pageId) { $pageRepo = $this->entityManager->getRepository(Page::class); $page = $pageRepo->findOneBy([ "id" => $pageId ]); $elementTypes = $page->getCdf()->getExport()->getProject()->getElementTypes(); } else if (null !== $export) { $elementTypes = $export->getProject()->getElementTypes(); } else { $elementTypes = []; } $elementTypeFieldsPIM = []; foreach ($elementTypes as $elementType) { if (!empty($elementType->getElementTypeFieldsPIM())) { $elementTypeFieldsPIM = array_merge($elementTypeFieldsPIM, $elementType->getElementTypeFieldsPIM()); } } $collectElementValue = $this->collectElementValue->readMultiple($elementIds, $elementTypeFieldsPIM, $allFields); if (!empty($collectElementValue)) { $entityValue = $collectElementValue['data']; } else { $entityValue = []; } $this->logService->setLog('End readCollectElement function'); return $entityValue; } public function prepareValuePim($elementId, $fields, $variableId, $layoutId) { $layoutRepo = $this->entityManager->getRepository(Layout::class); $variableRepo = $this->entityManager->getRepository(Variable::class); $layout = $layoutRepo->findOneBy([ // element_type_template_configuration "id" => $layoutId, "deletedAt" => null, ]); $variable = $variableRepo->findOneBy([ "id" => $variableId, "deletedAt" => null, ]); $result = []; $criteriaObj = new Criteria(); $criteriaObj->orderBy(["position" => Criteria::ASC]); $inputs = $variable->getInputs()->matching($criteriaObj); foreach ($inputs as $input) { if ($input->getDeletedAt() == null && !empty($input->getVariableProject())) { $inp = [ "name" => $input->getVariableProject()->getName(), "value" => "", "valuePimId" => null, "valueProjectId" => null, "fieldType" => !empty($input->getFieldType()) ? $input->getFieldType() : "textarea", "listValue" => !empty($input->getListValue()) ? $input->getListValue() : [], "collection" => $elementId, "variableProjectId" => $input->getVariableProject()->getId(), "pimInputId" => null, "twigVar" => $input->getVariableName(), "editable" => true ]; $layoutFilter = array_filter($layout->getInputs(), static function ($layoutInp) use ($input) { return $input->getVariableProject()->getId() === (int) $layoutInp['variableProjectId']; }); $filterInput = null; if (!empty($layoutFilter)) { if (array_key_exists(reset($layoutFilter)['inputId'], $fields)) { $filterInput = $fields[reset($layoutFilter)['inputId']]; } if (!empty($filterInput)) { $inp = [ "name" => $input->getVariableProject()->getName(), "value" => !empty($val) ? $val->getValue() : $filterInput["value"], "valuePimId" => $filterInput["id"] ?? null, "valueProjectId" => !empty($val) ? $val->getId() : null, "fieldType" => isset($filterInput["fieldType"]) ? $filterInput["fieldType"] : (!empty($input->getFieldType()) ? $input->getFieldType() : "textarea"), "listValue" => $filterInput["listValue"] ?? [], "collection" => $collection ?? 0, "variableProjectId" => $input->getVariableProject()->getId(), "pimInputId" => reset($layoutFilter)['inputId'], "twigVar" => $input->getVariableName(), "editable" => !empty($pageDuplicateId) ? reset($layoutFilter)['editable'] : true ]; } if ($inp['fieldType'] === "list" || $inp['fieldType'] === "list multiple") { $result[] = new InputListTemplateNameView( $inp['name'], $inp['value'], $inp['valuePimId'], $inp['valueProjectId'], $inp['fieldType'], is_array($inp['listValue']) ? $inp['listValue'] : json_decode($inp['listValue'], true), $inp['collection'], $inp['variableProjectId'], $inp['pimInputId'], $inp['twigVar'], $inp['editable'] ); } else { $result[] = new InputTemplateNameView( $inp['name'], $inp['value'], $inp['valuePimId'], $inp['valueProjectId'], $inp['fieldType'], $inp['collection'], $inp['variableProjectId'], $inp['pimInputId'], $inp['twigVar'], $inp['editable'], isset($inp["multiple"]) ? $inp["multiple"] : false ); } } } } return $result; } }