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
e0b6541b
Commit
e0b6541b
authored
Nov 01, 2016
by
Simon Gadient
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IMP] Preview error handling
refs KIME-4583
parent
79dc5c5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
Classes/WE/SpreadsheetImport/FrontendMappingService.php
Classes/WE/SpreadsheetImport/FrontendMappingService.php
+20
-4
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
+2
-1
No files found.
Classes/WE/SpreadsheetImport/FrontendMappingService.php
View file @
e0b6541b
...
@@ -14,6 +14,7 @@ namespace WE\SpreadsheetImport;
...
@@ -14,6 +14,7 @@ namespace WE\SpreadsheetImport;
use
TYPO3\Flow\Annotations
as
Flow
;
use
TYPO3\Flow\Annotations
as
Flow
;
use
TYPO3\Flow\Mvc\ActionRequest
;
use
TYPO3\Flow\Mvc\ActionRequest
;
use
WE\SpreadsheetImport\Annotations\Mapping
;
use
WE\SpreadsheetImport\Annotations\Mapping
;
use
WE\SpreadsheetImport\Domain\Model\SpreadsheetImport
;
/**
/**
* Service class of basic FE mapping functionality for simple usage on separate implementations.
* Service class of basic FE mapping functionality for simple usage on separate implementations.
...
@@ -46,6 +47,12 @@ class FrontendMappingService {
...
@@ -46,6 +47,12 @@ class FrontendMappingService {
*/
*/
protected
$propertyMapper
;
protected
$propertyMapper
;
/**
* @Flow\Inject
* @var \TYPO3\Flow\Validation\ValidatorResolver
*/
protected
$validatorResolver
;
/**
/**
* @param string $context
* @param string $context
* @param \TYPO3\Flow\Mvc\ActionRequest $request
* @param \TYPO3\Flow\Mvc\ActionRequest $request
...
@@ -93,21 +100,30 @@ class FrontendMappingService {
...
@@ -93,21 +100,30 @@ class FrontendMappingService {
}
}
/**
/**
* @param
array $mapping
* @param
\WE\SpreadsheetImport\Domain\Model\SpreadsheetImport $spreadsheetImport
* @param
int
$record
* @param $record
*
*
* @return array
* @return array
*/
*/
public
function
getMappingPreview
(
$mapping
,
$record
)
{
public
function
getMappingPreview
(
SpreadsheetImport
$spreadsheetImport
,
$record
)
{
$mapping
=
$spreadsheetImport
->
getMapping
();
$domain
=
$this
->
settings
[
$spreadsheetImport
->
getContext
()][
'domain'
];
$record
=
max
(
$record
,
1
);
$record
=
max
(
$record
,
1
);
$previewObject
=
$this
->
spreadsheetImportService
->
getObjectByRow
(
$record
);
$previewObject
=
$this
->
spreadsheetImportService
->
getObjectByRow
(
$record
);
$preview
=
array
();
$preview
=
array
();
$hasErrors
=
FALSE
;
$objectValidator
=
$this
->
validatorResolver
->
getBaseValidatorConjunction
(
$domain
);
$errors
=
$objectValidator
->
validate
(
$previewObject
)
->
getFlattenedErrors
();
foreach
(
$mapping
as
$property
=>
$columnMapping
)
{
foreach
(
$mapping
as
$property
=>
$columnMapping
)
{
/** @var Mapping $mapping */
/** @var Mapping $mapping */
$mapping
=
$columnMapping
[
'mapping'
];
$mapping
=
$columnMapping
[
'mapping'
];
$getter
=
empty
(
$mapping
->
getter
)
?
'get'
.
ucfirst
(
$property
)
:
$mapping
->
getter
;
$getter
=
empty
(
$mapping
->
getter
)
?
'get'
.
ucfirst
(
$property
)
:
$mapping
->
getter
;
$preview
[
$property
]
=
array
(
'value'
=>
$previewObject
->
$getter
(),
'mapping'
=>
$mapping
);
$preview
[
$property
]
=
array
(
'value'
=>
$previewObject
->
$getter
(),
'mapping'
=>
$mapping
);
if
(
isset
(
$errors
[
$property
]))
{
$preview
[
$property
][
'error'
]
=
$errors
[
$property
];
$hasErrors
=
TRUE
;
}
}
}
return
$preview
;
return
array
(
'preview'
=>
$preview
,
'hasErrors'
=>
$hasErrors
)
;
}
}
}
}
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
View file @
e0b6541b
...
@@ -340,6 +340,8 @@ class SpreadsheetImportService {
...
@@ -340,6 +340,8 @@ class SpreadsheetImportService {
* @param \PHPExcel_Worksheet_Row $row
* @param \PHPExcel_Worksheet_Row $row
*/
*/
private
function
setObjectPropertiesByRow
(
$object
,
$row
)
{
private
function
setObjectPropertiesByRow
(
$object
,
$row
)
{
// Set the arguments first as mapping property setters might be dependent on argument properties
$this
->
setObjectArgumentProperties
(
$object
);
$inverseSpreadsheetImportMapping
=
$this
->
getInverseSpreadsheetImportMapping
();
$inverseSpreadsheetImportMapping
=
$this
->
getInverseSpreadsheetImportMapping
();
/** @var \PHPExcel_Cell $cell */
/** @var \PHPExcel_Cell $cell */
foreach
(
$row
->
getCellIterator
()
as
$cell
)
{
foreach
(
$row
->
getCellIterator
()
as
$cell
)
{
...
@@ -355,7 +357,6 @@ class SpreadsheetImportService {
...
@@ -355,7 +357,6 @@ class SpreadsheetImportService {
}
}
}
}
}
}
$this
->
setObjectArgumentProperties
(
$object
);
}
}
/**
/**
...
...
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