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
bdccb6b4
Commit
bdccb6b4
authored
Feb 26, 2021
by
Laura Heimann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create APIConnectPlaylistController.php
parent
ef4b3063
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
0 deletions
+101
-0
src/Controller/API/Connect/APIConnectPlaylistController.php
src/Controller/API/Connect/APIConnectPlaylistController.php
+101
-0
No files found.
src/Controller/API/Connect/APIConnectPlaylistController.php
0 → 100644
View file @
bdccb6b4
<?php
namespace
App\Controller\API\Connect
;
use
Symfony\Bundle\FrameworkBundle\Controller\AbstractController
;
use
Symfony\Component\Routing\Generator\UrlGeneratorInterface
;
use
Symfony\Component\Routing\Annotation\Route
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpClient\HttpClient
;
use
App\Entity\User
;
use
App\Entity\Connection
;
use
App\Entity\ConnectApp
;
use
App\Entity\Song
;
use
App\Entity\SongPlaylist
;
use
App\Entity\UserNotification
;
class
APIConnectPlaylistController
extends
AbstractController
{
/**
* @Route("/api/connect/playlists", name="api.connect.playlists")
* @Route("/api/connect/playlists/")
*/
public
function
getPlaylists
(
Request
$request
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$connectToken
=
$request
->
query
->
get
(
'connectToken'
);
if
(
$connectToken
==
""
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
$connection
=
$em
->
getRepository
(
Connection
::
class
)
->
findOneBy
(
array
(
'connectToken'
=>
$connectToken
));
if
(
$connection
)
{
foreach
(
$connection
->
getUser
()
->
getSongPlaylists
()
as
$playlist
)
{
$data
[]
=
$playlist
->
getJSON
();
}
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
return
$response
;
}
else
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
}
/**
* @Route("/api/connect/savePlaylists/{songID}/", name="api.connect.savePlaylists")
* @Route("/api/connect/savePlaylists/{songID}")
*/
public
function
savePlaylists
(
Request
$request
,
int
$songID
)
{
$em
=
$this
->
getDoctrine
()
->
getManager
();
$data
=
[];
$connectToken
=
$request
->
query
->
get
(
'connectToken'
);
//$jsonBody = json_decode($request->getContent(), true);
if
(
$connectToken
==
""
)
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
$connection
=
$em
->
getRepository
(
Connection
::
class
)
->
findOneBy
(
array
(
'connectToken'
=>
$connectToken
));
if
(
$connection
)
{
//$playlistsToSaveTo = $jsonBody['playlists'];
/*
*
* FUCK THIS, THIS IS BROKEN, WTF WHY IS IT RECURSIVE???
*
*/
$song
=
$em
->
getRepository
(
Song
::
class
)
->
findOneBy
(
array
(
'id'
=>
$songID
));
var_dump
(
$song
->
getSongPlaylists
());
// Remove all playlist Entries
//$playlistsByUser = $em->getRepository(SongPlaylist::class)->findBy(array('user' => $connection->getUser()));
// Add to all playlists
//var_dump($playlistsByUser);
//var_dump($playlistsToSaveTo);
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
200
,
'data'
=>
$data
]);
return
$response
;
}
else
{
$response
=
new
JsonResponse
([
'version'
=>
$this
->
getParameter
(
'api_version'
),
'status'
=>
403
,
'data'
=>
[]]);
return
$response
;
}
}
}
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