EntryPointsController::viewAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 15
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 25
rs 9.7666
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 Generated\Shared\Transfer\PunchoutCatalogEntryPointFilterTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ntryPointFilterTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
12
use Symfony\Component\HttpFoundation\Request;
13
14
/**
15
 * @method \SprykerEco\Zed\PunchoutCatalogs\Persistence\PunchoutCatalogsRepositoryInterface getRepository()
16
 * @method \SprykerEco\Zed\PunchoutCatalogs\Business\PunchoutCatalogsFacadeInterface getFacade()
17
 * @method \SprykerEco\Zed\PunchoutCatalogs\Communication\PunchoutCatalogsCommunicationFactory getFactory()
18
 */
19
class EntryPointsController extends AbstractController
20
{
21
    /**
22
     * @see \SprykerEco\Zed\PunchoutCatalogs\Communication\Controller\IndexController::indexAction()
23
     */
24
    protected const ROUTE_PUNCHOUT_CATALOGS_CONNECTION_LIST_PAGE = '/punchout-catalogs/';
25
26
    protected const PARAM_ID_PUNCHOUT_CATALOG_CONNECTION = 'id-punchout-catalog-connection';
27
28
    protected const MESSAGE_CONNECTION_NOT_FOUND = 'Connection not found';
29
30
    /**
31
     * @param \Symfony\Component\HttpFoundation\Request $request
32
     *
33
     * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
34
     */
35
    public function viewAction(Request $request)
36
    {
37
        $idPunchoutCatalogConnection = $this->castId(
38
            $request->query->get(static::PARAM_ID_PUNCHOUT_CATALOG_CONNECTION)
39
        );
40
41
        $punchoutCatalogConnectionTransfer = $this->getFacade()
42
            ->findConnectionById($idPunchoutCatalogConnection);
43
44
        if (!$punchoutCatalogConnectionTransfer) {
45
            $this->addErrorMessage(static::MESSAGE_CONNECTION_NOT_FOUND);
46
47
            return $this->redirectResponse(static::ROUTE_PUNCHOUT_CATALOGS_CONNECTION_LIST_PAGE);
48
        }
49
50
        $punchoutCatalogEntryPointFilterTransfer = (new PunchoutCatalogEntryPointFilterTransfer())
51
            ->setIdCompanyBusinessUnit($punchoutCatalogConnectionTransfer->getFkCompanyBusinessUnit());
52
53
        $punchoutCatalogEntryPointTransfer = $this->getFactory()
54
            ->getPunchoutCatalogFacade()
55
            ->getRequestEntryPointsByBusinessUnit($punchoutCatalogEntryPointFilterTransfer);
56
57
        return [
58
            'punchoutCatalogEntryPoints' => $punchoutCatalogEntryPointTransfer,
59
            'punchoutCatalogConnection' => $punchoutCatalogConnectionTransfer,
60
        ];
61
    }
62
}
63