Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
WE.SpreadsheetImport
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Labels
Merge Requests
0
Merge Requests
0
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
packages
WE.SpreadsheetImport
Commits
bfb16fff
Commit
bfb16fff
authored
Oct 26, 2016
by
Simon Gadient
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IMP] Frontend mapping utility functions
refs KIME-4583
parent
bea705cc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
Classes/WE/SpreadsheetImport/FrontendMappingUtility.php
Classes/WE/SpreadsheetImport/FrontendMappingUtility.php
+55
-0
No files found.
Classes/WE/SpreadsheetImport/FrontendMappingUtility.php
0 → 100644
View file @
bfb16fff
<?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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment