Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
ldap
Commits
82796fdf
Commit
82796fdf
authored
Dec 02, 2020
by
David Surville
Browse files
Meilleure gestion du setter de l'attribut "unicaenServiceEtat"
parent
a421d20a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/UnicaenLdap/Entity/Base/People.php
View file @
82796fdf
...
...
@@ -1572,11 +1572,40 @@ class People extends Entity
public
function
setUnicaenServiceEtat
(
$value
=
null
,
$append
=
false
)
{
$value
=
$this
->
preFormat
(
$value
);
$value
=
array_filter
(
$value
,
function
(
$v
)
{
return
preg_match
(
self
::
$service_etat_pattern
,
$v
);
});
$this
->
appendOrNot
(
'unicaenServiceEtat'
,
$value
,
$append
);
if
(
empty
(
$value
))
{
$this
->
appendOrNot
(
'unicaenServiceEtat'
,
$value
,
false
);
}
if
(
$append
)
{
$this
->
appendOrNot
(
'unicaenServiceEtat'
,
$value
,
true
);
}
$newValues
=
[];
foreach
(
$value
as
$v
)
{
if
(
preg_match
(
self
::
$service_etat_pattern
,
$v
,
$matches
))
{
$newValues
[
$matches
[
'etiquette'
]][]
=
$matches
[
'value'
];
}
};
foreach
(
$newValues
as
$label
=>
$values
)
{
$currentValues
=
$this
->
preFormat
(
$this
->
unicaenServiceEtat
);
array_walk
(
$currentValues
,
function
(
&
$cv
)
use
(
$label
,
$values
)
{
if
(
preg_match
(
"/^"
.
$label
.
"(?<value>.+)$/"
,
$cv
,
$matches
))
{
if
(
!
in_array
(
$matches
[
'value'
],
$values
))
{
$this
->
remove
(
'unicaenServiceEtat'
,
$cv
);
$cv
=
null
;
}
}
});
foreach
(
$values
as
$v
)
{
$v
=
$label
.
$v
;
if
(
!
in_array
(
$v
,
$currentValues
))
{
$currentValues
[]
=
$v
;
}
}
$this
->
appendOrNot
(
'unicaenServiceEtat'
,
array_filter
(
$currentValues
),
false
);
}
return
$this
;
}
...
...
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