Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
Backend Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SpinShare
Backend Server
Commits
8a886d0e
Commit
8a886d0e
authored
Feb 23, 2021
by
Laura Heimann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minimized promo code, added activePromos api endpoint
parent
3143cb7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
13 deletions
+43
-13
src/Controller/API/APIPromosController.php
src/Controller/API/APIPromosController.php
+27
-13
src/Entity/Promo.php
src/Entity/Promo.php
+16
-0
No files found.
src/Controller/API/APIPromosController.php
View file @
8a886d0e
...
@@ -25,6 +25,8 @@ class APIPromosController extends AbstractController
...
@@ -25,6 +25,8 @@ class APIPromosController extends AbstractController
*/
*/
public
function
promos
(
Request
$request
)
public
function
promos
(
Request
$request
)
{
{
// TODO: DEPRECATION
$em
=
$this
->
getDoctrine
()
->
getManager
();
$em
=
$this
->
getDoctrine
()
->
getManager
();
$results
=
$em
->
getRepository
(
Promo
::
class
)
->
findBy
(
array
(
'isVisible'
=>
true
),
array
(
'id'
=>
'DESC'
),
2
);
$results
=
$em
->
getRepository
(
Promo
::
class
)
->
findBy
(
array
(
'isVisible'
=>
true
),
array
(
'id'
=>
'DESC'
),
2
);
...
@@ -35,19 +37,31 @@ class APIPromosController extends AbstractController
...
@@ -35,19 +37,31 @@ class APIPromosController extends AbstractController
return
$response
;
return
$response
;
}
else
{
}
else
{
foreach
(
$results
as
$result
)
{
foreach
(
$results
as
$result
)
{
$oneResult
=
[];
$data
[]
=
$result
->
getJSON
();
}
$oneResult
[
'id'
]
=
$result
->
getId
();
$oneResult
[
'title'
]
=
$result
->
getTitle
();
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
$oneResult
[
'type'
]
=
$result
->
getType
();
return
$response
;
$oneResult
[
'textColor'
]
=
$result
->
getTextColor
();
}
$oneResult
[
'color'
]
=
$result
->
getColor
();
}
$oneResult
[
'button'
][
'type'
]
=
$result
->
getButtonType
();
$oneResult
[
'button'
][
'data'
]
=
$result
->
getButtonData
();
/**
$oneResult
[
'isVisible'
]
=
$result
->
getIsVisible
();
* @Route("/api/activePromos", name="api.activePromos")
$oneResult
[
'image_path'
]
=
$baseUrl
.
"/uploads/promo/"
.
$result
->
getImagePath
();
* @Route("/api/activePromos/")
*/
$data
[]
=
$oneResult
;
public
function
activePromos
(
Request
$request
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$results
=
$em
->
getRepository
(
Promo
::
class
)
->
findBy
(
array
(
'isVisible'
=>
true
),
array
(
'id'
=>
'DESC'
));
$baseUrl
=
$request
->
getScheme
()
.
'://'
.
$request
->
getHttpHost
()
.
$request
->
getBasePath
();
if
(
!
$results
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
404
,
'data'
=>
[]]);
return
$response
;
}
else
{
foreach
(
$results
as
$result
)
{
$data
[]
=
$result
->
getJSON
();
}
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
...
...
src/Entity/Promo.php
View file @
8a886d0e
...
@@ -156,4 +156,20 @@ class Promo
...
@@ -156,4 +156,20 @@ class Promo
return
$this
;
return
$this
;
}
}
public
function
getJSON
()
{
return
array
(
'id'
=>
$this
->
id
,
'title'
=>
$this
->
title
,
'type'
=>
$this
->
type
,
'textColor'
=>
$this
->
textColor
,
'color'
=>
$this
->
color
,
'button'
=>
array
(
'type'
=>
$this
->
buttonType
,
'data'
=>
$this
->
buttonData
),
'isVisible'
=>
$this
->
isVisible
,
'image_path'
=>
$_ENV
[
'ASSET_BASE_URL'
]
.
"/"
.
$_ENV
[
'ASSET_PROMO_FOLDER'
]
.
"/"
.
$this
->
imagePath
,
);
}
}
}
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