Code Duplication    Length = 19-21 lines in 6 locations

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

@@ 65-85 (lines=21) @@
62
     *
63
     * @return array
64
     */
65
    public function getBasicNodeData($nodeId)
66
    {
67
        $query = $this->handler->createSelectQuery();
68
        $query
69
            ->select('*')
70
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
71
            ->where(
72
                $query->expr->eq(
73
                    $this->handler->quoteColumn('node_id'),
74
                    $query->bindValue($nodeId)
75
                )
76
            );
77
        $statement = $query->prepare();
78
        $statement->execute();
79
80
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
81
            return $row;
82
        }
83
84
        throw new NotFound('location', $nodeId);
85
    }
86
87
    /**
88
     * Returns an array with basic node data.
@@ 96-116 (lines=21) @@
93
     *
94
     * @return array
95
     */
96
    public function getBasicNodeDataByRemoteId($remoteId)
97
    {
98
        $query = $this->handler->createSelectQuery();
99
        $query
100
            ->select('*')
101
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
102
            ->where(
103
                $query->expr->eq(
104
                    $this->handler->quoteColumn('remote_id'),
105
                    $query->bindValue($remoteId)
106
                )
107
            );
108
        $statement = $query->prepare();
109
        $statement->execute();
110
111
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
112
            return $row;
113
        }
114
115
        throw new NotFound('location', $remoteId);
116
    }
117
118
    /**
119
     * Loads data for all Locations for $contentId, optionally only in the
@@ 1219-1239 (lines=21) @@
1216
     *
1217
     * @return array
1218
     */
1219
    public function loadTrashByLocation($locationId)
1220
    {
1221
        $query = $this->handler->createSelectQuery();
1222
        $query
1223
            ->select('*')
1224
            ->from($this->handler->quoteTable('ezcontentobject_trash'))
1225
            ->where(
1226
                $query->expr->eq(
1227
                    $this->handler->quoteColumn('node_id'),
1228
                    $query->bindValue($locationId)
1229
                )
1230
            );
1231
        $statement = $query->prepare();
1232
        $statement->execute();
1233
1234
        if ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
1235
            return $row;
1236
        }
1237
1238
        throw new NotFound('trash', $locationId);
1239
    }
1240
1241
    /**
1242
     * Loads trash data specified by content ID.
@@ 1248-1266 (lines=19) @@
1245
     *
1246
     * @return array
1247
     */
1248
    public function loadTrashByContent($contentId)
1249
    {
1250
        $query = $this->handler->createSelectQuery();
1251
        $query
1252
            ->select('*')
1253
            ->from($this->handler->quoteTable('ezcontentobject_trash'))
1254
            ->where(
1255
                $query->expr->eq(
1256
                    $this->handler->quoteColumn('contentobject_id'),
1257
                    $query->bindValue($contentId)
1258
                )
1259
            );
1260
        $statement = $query->prepare();
1261
        $statement->execute();
1262
1263
        $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
1264
1265
        return $rows;
1266
    }
1267
1268
    /**
1269
     * List trashed items.

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

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