1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the SaasProviderBundle package. |
5
|
|
|
* (c) Fluxter <http://fluxter.net/> |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Fluxter\SaasProviderBundle\Controller; |
11
|
|
|
|
12
|
|
|
use Fluxter\SaasProviderBundle\Form\CreateClientType; |
13
|
|
|
use Fluxter\SaasProviderBundle\Model\SaasClientInterface; |
14
|
|
|
use Fluxter\SaasProviderBundle\Service\SaasClientService; |
15
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
18
|
|
|
|
19
|
|
|
class SaasClientController extends AbstractController |
20
|
|
|
{ |
21
|
|
|
/** @var SaasClientService */ |
22
|
|
|
private $clientService; |
23
|
|
|
|
24
|
|
|
private $clientEntity; |
25
|
|
|
|
26
|
|
|
public function __construct(SaasClientService $clientService, ContainerInterface $container) |
27
|
|
|
{ |
28
|
|
|
$this->clientService = $clientService; |
29
|
|
|
$this->clientEntity = $container->getParameter('saas_provider.client_entity'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function createClientAction(Request $request, string $apikey) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
// Todo check the apikey |
35
|
|
|
|
36
|
|
|
/** @var SaasClientInterface $client */ |
37
|
|
|
$client = new $this->clientEntity(); |
38
|
|
|
$form = $this->createForm(CreateClientType::class, $client); |
39
|
|
|
$form->handleRequest($request); |
40
|
|
|
if (!$form->isSubmitted() || !$form->isValid()) { |
41
|
|
|
return $this->json($form, 400); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$this->clientService->createClient($form->get('parameters')->getData()); |
45
|
|
|
|
46
|
|
|
return $this->json(['success' => true]); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.