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
bea705cc
Commit
bea705cc
authored
Oct 26, 2016
by
Simon Gadient
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IMP] Additional mapping property support
refs KIME-4583
parent
fed606d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
8 deletions
+43
-8
Classes/WE/SpreadsheetImport/Annotations/Mapping.php
Classes/WE/SpreadsheetImport/Annotations/Mapping.php
+13
-0
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
+29
-6
Configuration/Testing/Settings.yaml
Configuration/Testing/Settings.yaml
+0
-1
Tests/Functional/SpreadsheetImportServiceTest.php
Tests/Functional/SpreadsheetImportServiceTest.php
+1
-1
No files found.
Classes/WE/SpreadsheetImport/Annotations/Mapping.php
View file @
bea705cc
...
@@ -20,16 +20,29 @@ namespace WE\SpreadsheetImport\Annotations;
...
@@ -20,16 +20,29 @@ namespace WE\SpreadsheetImport\Annotations;
final
class
Mapping
{
final
class
Mapping
{
/**
/**
* Label id for the property mapping
*
* @var string
* @var string
*/
*/
public
$labelId
=
''
;
public
$labelId
=
''
;
/**
/**
* Flag if property is handled as an identifier for updates
*
* @var boolean
* @var boolean
*/
*/
public
$identifier
=
FALSE
;
public
$identifier
=
FALSE
;
/**
/**
* Overwrite the default getter for previews
*
* @var string
*/
public
$getter
;
/**
* Overwrite the default setter
*
* @var string
* @var string
*/
*/
public
$setter
;
public
$setter
;
...
...
Classes/WE/SpreadsheetImport/SpreadsheetImportService.php
View file @
bea705cc
...
@@ -30,6 +30,11 @@ class SpreadsheetImportService {
...
@@ -30,6 +30,11 @@ class SpreadsheetImportService {
*/
*/
protected
$context
;
protected
$context
;
/**
* @var array
*/
protected
$mappingProperties
;
/**
/**
* @Flow\InjectConfiguration
* @Flow\InjectConfiguration
* @var array
* @var array
...
@@ -68,19 +73,37 @@ class SpreadsheetImportService {
...
@@ -68,19 +73,37 @@ class SpreadsheetImportService {
public
function
init
(
SpreadsheetImport
$spreadsheetImport
)
{
public
function
init
(
SpreadsheetImport
$spreadsheetImport
)
{
$this
->
spreadsheetImport
=
$spreadsheetImport
;
$this
->
spreadsheetImport
=
$spreadsheetImport
;
$this
->
context
=
$this
->
settings
[
$spreadsheetImport
->
getContext
()];
$this
->
context
=
$this
->
settings
[
$spreadsheetImport
->
getContext
()];
$this
->
initDomainMappingProperties
();
return
$this
;
return
$this
;
}
}
/**
/**
*
@return array
*
Initializes the properties declared by annotations.
*/
*/
p
ublic
function
ge
tDomainMappingProperties
()
{
p
rivate
function
ini
tDomainMappingProperties
()
{
$
domainM
appingProperties
=
array
();
$
this
->
m
appingProperties
=
array
();
$properties
=
$this
->
reflectionService
->
getPropertyNamesByAnnotation
(
$this
->
context
[
'domain'
],
Mapping
::
class
);
$properties
=
$this
->
reflectionService
->
getPropertyNamesByAnnotation
(
$this
->
context
[
'domain'
],
Mapping
::
class
);
foreach
(
$properties
as
$property
)
{
foreach
(
$properties
as
$property
)
{
$
domainM
appingProperties
[
$property
]
=
$this
->
reflectionService
->
getPropertyAnnotation
(
$this
->
context
[
'domain'
],
$property
,
Mapping
::
class
);
$
this
->
m
appingProperties
[
$property
]
=
$this
->
reflectionService
->
getPropertyAnnotation
(
$this
->
context
[
'domain'
],
$property
,
Mapping
::
class
);
}
}
return
$domainMappingProperties
;
}
/**
* Adds additional mapping properties to the domain mapping properties retrieved by annotations. This increases
* flexibility for dynamic property mapping.
*
* @param array $additionalMappingProperties
*/
public
function
addAdditionalMappingProperties
(
array
$additionalMappingProperties
)
{
$this
->
mappingProperties
=
array_merge
(
$this
->
mappingProperties
,
$additionalMappingProperties
);
}
/**
* @return array
*/
public
function
getMappingProperties
()
{
return
$this
->
mappingProperties
;
}
}
/**
/**
...
@@ -244,7 +267,7 @@ class SpreadsheetImportService {
...
@@ -244,7 +267,7 @@ class SpreadsheetImportService {
*/
*/
private
function
setObjectPropertiesByRow
(
$newObject
,
$row
)
{
private
function
setObjectPropertiesByRow
(
$newObject
,
$row
)
{
// TODO: Cache $domainMappingProperties and $mappings
// TODO: Cache $domainMappingProperties and $mappings
$domainMappingProperties
=
$this
->
get
Domain
MappingProperties
();
$domainMappingProperties
=
$this
->
getMappingProperties
();
$mappings
=
$this
->
spreadsheetImport
->
getMapping
();
$mappings
=
$this
->
spreadsheetImport
->
getMapping
();
/** @var \PHPExcel_Cell $cell */
/** @var \PHPExcel_Cell $cell */
foreach
(
$row
->
getCellIterator
()
as
$cell
)
{
foreach
(
$row
->
getCellIterator
()
as
$cell
)
{
...
...
Configuration/Testing/Settings.yaml
View file @
bea705cc
...
@@ -2,7 +2,6 @@ WE:
...
@@ -2,7 +2,6 @@ WE:
SpreadsheetImport
:
SpreadsheetImport
:
testing
:
testing
:
domain
:
WE\SpreadsheetImport\Tests\Functional\Fixtures\ImportTarget
domain
:
WE\SpreadsheetImport\Tests\Functional\Fixtures\ImportTarget
labelPackageKey
:
'
WE.SpreadsheetImport'
Configuration
:
Configuration
:
userProfileType
:
userProfileType
:
setter
:
convertUserProfileTypeBySysValue
setter
:
convertUserProfileTypeBySysValue
...
...
Tests/Functional/SpreadsheetImportServiceTest.php
View file @
bea705cc
...
@@ -71,7 +71,7 @@ class SpreadsheetImportServiceTest extends FunctionalTestCase {
...
@@ -71,7 +71,7 @@ class SpreadsheetImportServiceTest extends FunctionalTestCase {
* @test
* @test
*/
*/
public
function
getMappingPropertiesReturnsPropertiesWithMappingAnnotation
()
{
public
function
getMappingPropertiesReturnsPropertiesWithMappingAnnotation
()
{
$properties
=
$this
->
spreadsheetImportService
->
get
Domain
MappingProperties
();
$properties
=
$this
->
spreadsheetImportService
->
getMappingProperties
();
$this
->
assertArrayHasKey
(
'id'
,
$properties
);
$this
->
assertArrayHasKey
(
'id'
,
$properties
);
$this
->
assertArrayHasKey
(
'name'
,
$properties
);
$this
->
assertArrayHasKey
(
'name'
,
$properties
);
/** @var Mapping $id */
/** @var Mapping $id */
...
...
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