Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-server
Commits
5be0dc78
Commit
5be0dc78
authored
Mar 17, 2020
by
François Agneray
Browse files
#41
=> done
parent
44aed2d9
Pipeline
#2156
passed with stages
in 6 minutes
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Action/InstanceAction.php
View file @
5be0dc78
...
...
@@ -56,7 +56,7 @@ final class InstanceAction extends AbstractAction
$parsedBody
=
$request
->
getParsedBody
();
// If mandatories empty fields 400
foreach
(
array
(
'label'
,
'client_url'
)
as
$a
)
{
foreach
(
array
(
'label'
)
as
$a
)
{
if
(
$this
->
isEmptyField
(
$a
,
$parsedBody
))
{
throw
new
HttpBadRequestException
(
$request
,
...
...
@@ -89,7 +89,11 @@ final class InstanceAction extends AbstractAction
private
function
editInstance
(
Instance
$instance
,
array
$parsedBody
):
void
{
$instance
->
setLabel
(
$parsedBody
[
'label'
]);
$instance
->
setClientUrl
(
$parsedBody
[
'client_url'
]);
if
(
!
$this
->
isEmptyField
(
'client_url'
,
$parsedBody
))
{
$instance
->
setClientUrl
(
$parsedBody
[
'client_url'
]);
}
else
{
$instance
->
setClientUrl
(
null
);
}
$this
->
em
->
flush
();
}
}
src/Action/InstanceListAction.php
View file @
5be0dc78
...
...
@@ -45,7 +45,7 @@ final class InstanceListAction extends AbstractAction
$parsedBody
=
$request
->
getParsedBody
();
// To work this action needs user information to update
foreach
(
array
(
'name'
,
'label'
,
'client_url'
)
as
$a
)
{
foreach
(
array
(
'name'
,
'label'
)
as
$a
)
{
if
(
$this
->
isEmptyField
(
$a
,
$parsedBody
))
{
throw
new
HttpBadRequestException
(
$request
,
...
...
@@ -71,7 +71,9 @@ final class InstanceListAction extends AbstractAction
private
function
postInstance
(
array
$parsedBody
):
Instance
{
$instance
=
new
Instance
(
$parsedBody
[
'name'
],
$parsedBody
[
'label'
]);
$instance
->
setClientUrl
(
$parsedBody
[
'client_url'
]);
if
(
!
$this
->
isEmptyField
(
'client_url'
,
$parsedBody
))
{
$instance
->
setClientUrl
(
$parsedBody
[
'client_url'
]);
}
$this
->
em
->
persist
(
$instance
);
$this
->
em
->
flush
();
...
...
src/Entity/Instance.php
View file @
5be0dc78
...
...
@@ -46,27 +46,27 @@ class Instance implements \JsonSerializable
$this
->
label
=
$label
;
}
public
function
getName
()
:
string
public
function
getName
()
{
return
$this
->
name
;
}
public
function
getLabel
()
:
string
public
function
getLabel
()
{
return
$this
->
label
;
}
public
function
setLabel
(
string
$label
)
:
void
public
function
setLabel
(
string
$label
)
{
$this
->
label
=
$label
;
}
public
function
getClientUrl
()
:
string
public
function
getClientUrl
()
{
return
$this
->
clientUrl
;
}
public
function
setClientUrl
(
$clientUrl
)
:
void
public
function
setClientUrl
(
$clientUrl
)
{
$this
->
clientUrl
=
$clientUrl
;
}
...
...
Write
Preview
Supports
Markdown
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