Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
730162f7
Commit
730162f7
authored
Jan 26, 2016
by
Carsten Rose
Browse files
HelperFormElement: new created
parent
3eb33091
Changes
1
Hide whitespace changes
Inline
Side-by-side
qfq/helper/HelperFormElement.php
0 → 100644
View file @
730162f7
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 1/26/16
* Time: 11:25 AM
*/
namespace
qfq
;
use
qfq
;
use
qfq\Store
;
use
qfq\exceptions\UserException
;
require_once
(
__DIR__
.
'/../../qfq/store/Store.php'
);
require_once
(
__DIR__
.
'/../../qfq/Constants.php'
);
require_once
(
__DIR__
.
'/../../qfq/helper/KeyValueStringParser.php'
);
require_once
(
__DIR__
.
'/../../qfq/exceptions/UserException.php'
);
class
HelperFormElement
{
/**
* Iterates over all FormElements in $elements.
* If $element['parameter'] exist and is filled: explode the content and apend them to the current FormElement Array.
*
* @param array $elements
* @throws UserException
*/
public
static
function
explodeParameter
(
array
&
$elements
)
{
// Iterate all FormElements
foreach
(
$elements
AS
$key
=>
$element
)
{
// Something to explode?
if
(
isset
(
$element
[
'parameter'
])
&&
$element
[
'parameter'
]
!==
''
)
{
// Explode
$arr
=
KeyValueStringParser
::
parse
(
$element
[
'parameter'
],
"="
,
"
\n
"
);
// Check if some of the exploded keys conflict with existing keys
$checkKeys
=
array_keys
(
$arr
);
foreach
(
$checkKeys
AS
$checkKey
)
{
if
(
isset
(
$element
[
$checkKey
]))
{
$store
=
Store
::
getInstance
();
$store
->
setVar
(
SYSTEM_FORM_ELEMENT
,
$element
[
'name'
]
.
' / '
.
$element
[
'id'
],
STORE_SYSTEM
);
$store
->
setVar
(
SYSTEM_FORM_ELEMENT_COLUMN
,
'parameter'
,
STORE_SYSTEM
);
throw
new
UserException
(
"Found reserved keyname '
$checkKey
'"
);
}
}
$elements
[
$key
]
=
array_merge
(
$element
,
$arr
);
}
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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