Loading Classes/WE/SpreadsheetImport/FrontendMappingUtility.php 0 → 100644 +55 −0 Changes for Classes/WE/SpreadsheetImport/FrontendMappingUtility.php: 55 added lines, 0 removed lines. Original line number Original line Diff line number Diff line <?php namespace WE\SpreadsheetImport; /* * * This script belongs to the Flow package "SpreadsheetImport". * * * * It is free software; you can redistribute it and/or modify it under * * the terms of the GNU Lesser General Public License, either version 3 * * of the License, or (at your option) any later version. * * * * The TYPO3 project - inspiring people to share! * * */ use TYPO3\Flow\Mvc\ActionRequest; use WE\SpreadsheetImport\Annotations\Mapping; /** * Utility class of basic FE mapping functionality for simple usage on separate implementations. */ class FrontendMappingUtility { /** * @param \WE\SpreadsheetImport\SpreadsheetImportService $spreadsheetImportService * @param \TYPO3\Flow\Mvc\ActionRequest $request * * @return array */ public static function getSpreadsheetImportMappingByRequest(SpreadsheetImportService $spreadsheetImportService, ActionRequest $request) { $mappings = array(); $domainMappingProperties = $spreadsheetImportService->getMappingProperties(); foreach ($domainMappingProperties as $property => $mapping) { $column = $request->getArgument($property); $mappings[$column] = $property; } return $mappings; } /** * @param \WE\SpreadsheetImport\SpreadsheetImportService $spreadsheetImportService * @param int $record * * @return array */ public static function getMappingPreview(SpreadsheetImportService $spreadsheetImportService, $record) { $domainMappingProperties = $spreadsheetImportService->getMappingProperties(); $previewObject = $spreadsheetImportService->getObjectByRow($record); $preview = array(); /** @var Mapping $mapping */ foreach ($domainMappingProperties as $property => $mapping) { $getter = empty($mapping->getter) ? 'get' . ucfirst($property) : $mapping->getter; $preview[$property] = $previewObject->$getter(); } return $preview; } } Loading
Classes/WE/SpreadsheetImport/FrontendMappingUtility.php 0 → 100644 +55 −0 Changes for Classes/WE/SpreadsheetImport/FrontendMappingUtility.php: 55 added lines, 0 removed lines. Original line number Original line Diff line number Diff line <?php namespace WE\SpreadsheetImport; /* * * This script belongs to the Flow package "SpreadsheetImport". * * * * It is free software; you can redistribute it and/or modify it under * * the terms of the GNU Lesser General Public License, either version 3 * * of the License, or (at your option) any later version. * * * * The TYPO3 project - inspiring people to share! * * */ use TYPO3\Flow\Mvc\ActionRequest; use WE\SpreadsheetImport\Annotations\Mapping; /** * Utility class of basic FE mapping functionality for simple usage on separate implementations. */ class FrontendMappingUtility { /** * @param \WE\SpreadsheetImport\SpreadsheetImportService $spreadsheetImportService * @param \TYPO3\Flow\Mvc\ActionRequest $request * * @return array */ public static function getSpreadsheetImportMappingByRequest(SpreadsheetImportService $spreadsheetImportService, ActionRequest $request) { $mappings = array(); $domainMappingProperties = $spreadsheetImportService->getMappingProperties(); foreach ($domainMappingProperties as $property => $mapping) { $column = $request->getArgument($property); $mappings[$column] = $property; } return $mappings; } /** * @param \WE\SpreadsheetImport\SpreadsheetImportService $spreadsheetImportService * @param int $record * * @return array */ public static function getMappingPreview(SpreadsheetImportService $spreadsheetImportService, $record) { $domainMappingProperties = $spreadsheetImportService->getMappingProperties(); $previewObject = $spreadsheetImportService->getObjectByRow($record); $preview = array(); /** @var Mapping $mapping */ foreach ($domainMappingProperties as $property => $mapping) { $getter = empty($mapping->getter) ? 'get' . ucfirst($property) : $mapping->getter; $preview[$property] = $previewObject->$getter(); } return $preview; } }