Code Duplication    Length = 20-21 lines in 6 locations

eZ/Publish/Core/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php 2 locations

@@ 916-935 (lines=20) @@
913
     *
914
     * @return array(int=>array(string=>mixed)) Data rows.
915
     */
916
    public function loadTypeDataByIdentifier($identifier, $status)
917
    {
918
        $q = $this->getLoadTypeQuery();
919
        $q->where(
920
            $q->expr->lAnd(
921
                $q->expr->eq(
922
                    $this->dbHandler->quoteColumn('identifier', 'ezcontentclass'),
923
                    $q->bindValue($identifier)
924
                ),
925
                $q->expr->eq(
926
                    $this->dbHandler->quoteColumn('version', 'ezcontentclass'),
927
                    $q->bindValue($status)
928
                )
929
            )
930
        );
931
        $stmt = $q->prepare();
932
        $stmt->execute();
933
934
        return $stmt->fetchAll(\PDO::FETCH_ASSOC);
935
    }
936
937
    /**
938
     * Loads an array with data about the type referred to by $remoteId in
@@ 946-965 (lines=20) @@
943
     *
944
     * @return array(int=>array(string=>mixed)) Data rows.
945
     */
946
    public function loadTypeDataByRemoteId($remoteId, $status)
947
    {
948
        $q = $this->getLoadTypeQuery();
949
        $q->where(
950
            $q->expr->lAnd(
951
                $q->expr->eq(
952
                    $this->dbHandler->quoteColumn('remote_id', 'ezcontentclass'),
953
                    $q->bindValue($remoteId)
954
                ),
955
                $q->expr->eq(
956
                    $this->dbHandler->quoteColumn('version', 'ezcontentclass'),
957
                    $q->bindValue($status)
958
                )
959
            )
960
        );
961
        $stmt = $q->prepare();
962
        $stmt->execute();
963
964
        return $stmt->fetchAll(\PDO::FETCH_ASSOC);
965
    }
966
967
    /**
968
     * Returns a basic query to retrieve Type data.

eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php 1 location

@@ 834-853 (lines=20) @@
831
     *
832
     * @return array
833
     */
834
    public function load($contentId, $version, array $translations = null)
835
    {
836
        $query = $this->queryBuilder->createFindQuery($translations);
837
        $query->where(
838
            $query->expr->lAnd(
839
                $query->expr->eq(
840
                    $this->dbHandler->quoteColumn('id', 'ezcontentobject'),
841
                    $query->bindValue($contentId)
842
                ),
843
                $query->expr->eq(
844
                    $this->dbHandler->quoteColumn('version', 'ezcontentobject_version'),
845
                    $query->bindValue($version)
846
                )
847
            )
848
        );
849
        $statement = $query->prepare();
850
        $statement->execute();
851
852
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
853
    }
854
855
    /**
856
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php 3 locations

@@ 71-91 (lines=21) @@
68
     *
69
     * @return array
70
     */
71
    public function getBasicNodeData($nodeId)
72
    {
73
        $query = $this->handler->createSelectQuery();
74
        $query
75
            ->select('*')
76
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
77
            ->where(
78
                $query->expr->eq(
79
                    $this->handler->quoteColumn('node_id'),
80
                    $query->bindValue($nodeId)
81
                )
82
            );
83
        $statement = $query->prepare();
84
        $statement->execute();
85
86
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
87
            return $row;
88
        }
89
90
        throw new NotFound('location', $nodeId);
91
    }
92
93
    /**
94
     * Returns an array with basic node data.
@@ 102-122 (lines=21) @@
99
     *
100
     * @return array
101
     */
102
    public function getBasicNodeDataByRemoteId($remoteId)
103
    {
104
        $query = $this->handler->createSelectQuery();
105
        $query
106
            ->select('*')
107
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
108
            ->where(
109
                $query->expr->eq(
110
                    $this->handler->quoteColumn('remote_id'),
111
                    $query->bindValue($remoteId)
112
                )
113
            );
114
        $statement = $query->prepare();
115
        $statement->execute();
116
117
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
118
            return $row;
119
        }
120
121
        throw new NotFound('location', $remoteId);
122
    }
123
124
    /**
125
     * Loads data for all Locations for $contentId, optionally only in the
@@ 1225-1245 (lines=21) @@
1222
     *
1223
     * @return array
1224
     */
1225
    public function loadTrashByLocation($locationId)
1226
    {
1227
        $query = $this->handler->createSelectQuery();
1228
        $query
1229
            ->select('*')
1230
            ->from($this->handler->quoteTable('ezcontentobject_trash'))
1231
            ->where(
1232
                $query->expr->eq(
1233
                    $this->handler->quoteColumn('node_id'),
1234
                    $query->bindValue($locationId)
1235
                )
1236
            );
1237
        $statement = $query->prepare();
1238
        $statement->execute();
1239
1240
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
1241
            return $row;
1242
        }
1243
1244
        throw new NotFound('trash', $locationId);
1245
    }
1246
1247
    /**
1248
     * List trashed items.