PunchoutCatalogsRepository::findTransactionById()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 17
rs 9.8666
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\Persistence;
9
10
use Generated\Shared\Transfer\PunchoutCatalogConnectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...talogConnectionTransfer 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 Generated\Shared\Transfer\PunchoutCatalogTransactionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...alogTransactionTransfer 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...
12
use Orm\Zed\CompanyBusinessUnit\Persistence\Map\SpyCompanyBusinessUnitTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\CompanyBusinessU...anyBusinessUnitTableMap 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...
13
use Orm\Zed\CompanyUser\Persistence\Map\SpyCompanyUserTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\CompanyUser\Pers...\SpyCompanyUserTableMap 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...
14
use Propel\Runtime\ActiveQuery\Criteria;
15
use Spryker\Zed\Kernel\Persistence\AbstractRepository;
16
17
/**
18
 * @method \SprykerEco\Zed\PunchoutCatalogs\Persistence\PunchoutCatalogsPersistenceFactory getFactory()
19
 */
20
class PunchoutCatalogsRepository extends AbstractRepository implements PunchoutCatalogsRepositoryInterface
21
{
22
    /**
23
     * @param int $idConnection
24
     *
25
     * @return \Generated\Shared\Transfer\PunchoutCatalogConnectionTransfer|null
26
     */
27
    public function findConnectionById(int $idConnection): ?PunchoutCatalogConnectionTransfer
28
    {
29
        $punchoutCatalogConnectionEntity = $this->getFactory()
30
            ->getPunchoutCatalogConnectionPropelQuery()
31
            ->filterByIdPunchoutCatalogConnection($idConnection)
32
            ->leftJoinWithPgwPunchoutCatalogConnectionCart()
33
            ->leftJoinWithPgwPunchoutCatalogConnectionSetup()
34
            ->findOne();
35
36
        if ($punchoutCatalogConnectionEntity === null) {
37
            return null;
38
        }
39
40
        return $this->getFactory()
41
            ->createPunchoutCatalogsConnectionMapper()
42
            ->mapPunchoutCatalogConnectionEntityToTransfer(
43
                $punchoutCatalogConnectionEntity,
44
                new PunchoutCatalogConnectionTransfer()
45
            );
46
    }
47
48
    /**
49
     * @param int $idPunchoutCatalogTransaction
50
     *
51
     * @return \Generated\Shared\Transfer\PunchoutCatalogTransactionTransfer|null
52
     */
53
    public function findTransactionById(int $idPunchoutCatalogTransaction): ?PunchoutCatalogTransactionTransfer
54
    {
55
        $punchoutCatalogTransactionEntity = $this->getFactory()
56
            ->getPunchoutCatalogTransactionPropelQuery()
57
            ->leftJoinWithPunchoutCatalogConnection()
58
            ->filterByIdPunchoutCatalogTransaction($idPunchoutCatalogTransaction)
59
            ->findOne();
60
61
        if (!$punchoutCatalogTransactionEntity) {
62
            return null;
63
        }
64
65
        return $this->getFactory()
66
            ->createPunchoutCatalogsConnectionMapper()
67
            ->mapPunchoutCatalogTransactionEntityToTransfer(
68
                $punchoutCatalogTransactionEntity,
69
                new PunchoutCatalogTransactionTransfer()
70
            );
71
    }
72
73
    /**
74
     * @module CompanyBusinessUnit
75
     * @module Company
76
     * @module Customer
77
     *
78
     * @param int $idCompanyBusinessUnit
79
     *
80
     * @return int[]
81
     */
82
    public function getActiveCompanyUserIdsByIdCompanyBusinessUnit(int $idCompanyBusinessUnit): array
83
    {
84
        return $this->getFactory()
85
            ->getCompanyUserPropelQuery()
86
            ->useCompanyQuery(null, Criteria::INNER_JOIN)
87
                ->filterByIsActive(true)
88
            ->endUse()
89
            ->useCustomerQuery(null, Criteria::INNER_JOIN)
90
                ->filterByAnonymizedAt(null)
91
            ->endUse()
92
            ->filterByIsActive(true)
93
            ->filterByFkCompanyBusinessUnit($idCompanyBusinessUnit)
94
            ->select(SpyCompanyUserTableMap::COL_ID_COMPANY_USER)
95
            ->find()
96
            ->toArray();
97
    }
98
99
    /**
100
     * @module Company
101
     *
102
     * @param int $parentCompanyBusinessUnitId
103
     *
104
     * @return int[]
105
     */
106
    public function getActiveCompanyBusinessUnitIdsByParentCompanyBusinessUnitId(int $parentCompanyBusinessUnitId): array
107
    {
108
        return $this->getFactory()
109
            ->getCompanyBusinessUnitPropelQuery()
110
            ->useCompanyQuery(null, Criteria::INNER_JOIN)
111
                ->filterByIsActive(true)
112
            ->endUse()
113
            ->filterByFkParentCompanyBusinessUnit($parentCompanyBusinessUnitId)
114
            ->select(SpyCompanyBusinessUnitTableMap::COL_ID_COMPANY_BUSINESS_UNIT)
115
            ->find()
116
            ->toArray();
117
    }
118
}
119