CompanyUserController::indexAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\PunchoutCatalogs\Communication\Controller;
9
10
use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
11
use Symfony\Component\HttpFoundation\JsonResponse;
12
use Symfony\Component\HttpFoundation\Request;
13
14
/**
15
 * @method \SprykerEco\Zed\PunchoutCatalogs\Communication\PunchoutCatalogsCommunicationFactory getFactory()
16
 * @method \SprykerEco\Zed\PunchoutCatalogs\Business\PunchoutCatalogsFacadeInterface getFacade()
17
 * @method \SprykerEco\Zed\PunchoutCatalogs\Persistence\PunchoutCatalogsRepositoryInterface getRepository()
18
 */
19
class CompanyUserController extends AbstractController
20
{
21
    protected const PARAM_ID_COMPANY_BUSINESS_UNIT = 'id-company-business-unit';
22
23
    /**
24
     * @param \Symfony\Component\HttpFoundation\Request $request
25
     *
26
     * @return \Symfony\Component\HttpFoundation\JsonResponse
27
     */
28
    public function indexAction(Request $request): JsonResponse
29
    {
30
        $idCompanyBusinessUnit = $this->castId(
31
            $request->query->getInt(static::PARAM_ID_COMPANY_BUSINESS_UNIT)
32
        );
33
34
        $companyUserChoices = $this->getFactory()
35
            ->createPunchoutCatalogSetupRequestConnectionTypeFormDataProvider()
36
            ->getFormattedCompanyUserChoices($idCompanyBusinessUnit);
37
38
        return $this->jsonResponse($companyUserChoices);
39
    }
40
}
41