Code Duplication    Length = 17-23 lines in 8 locations

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

@@ 632-654 (lines=23) @@
629
     *
630
     * @return array
631
     */
632
    public function updateRole(RoleUpdateStruct $role)
633
    {
634
        $query = $this->handler->createUpdateQuery();
635
        $query
636
            ->update($this->handler->quoteTable('ezrole'))
637
            ->set(
638
                $this->handler->quoteColumn('name'),
639
                $query->bindValue($role->identifier)
640
            )->where(
641
                $query->expr->eq(
642
                    $this->handler->quoteColumn('id'),
643
                    $query->bindValue($role->id, null, \PDO::PARAM_INT)
644
                )
645
            );
646
        $statement = $query->prepare();
647
        $statement->execute();
648
649
        // Commented due to EZP-24698: Role update leads to NotFoundException
650
        // Should be fixed with PDO::MYSQL_ATTR_FOUND_ROWS instead
651
        /*if ($statement->rowCount() < 1) {
652
            throw new NotFoundException('role', $role->id);
653
        }*/
654
    }
655
656
    /**
657
     * Delete the specified role (draft).

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

@@ 309-325 (lines=17) @@
306
     * @param int $sectionId
307
     * @param int $contentId
308
     */
309
    public function assignSectionToContent($sectionId, $contentId)
310
    {
311
        $query = $this->dbHandler->createUpdateQuery();
312
        $query->update(
313
            $this->dbHandler->quoteTable('ezcontentobject')
314
        )->set(
315
            $this->dbHandler->quoteColumn('section_id'),
316
            $query->bindValue($sectionId, null, \PDO::PARAM_INT)
317
        )->where(
318
            $query->expr->eq(
319
                $this->dbHandler->quoteColumn('id'),
320
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
321
            )
322
        );
323
324
        $query->prepare()->execute();
325
    }
326
}
327

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

@@ 349-365 (lines=17) @@
346
     * @param int $oldStateId
347
     * @param int $newStateId
348
     */
349
    public function updateObjectStateLinks($oldStateId, $newStateId)
350
    {
351
        $query = $this->dbHandler->createUpdateQuery();
352
        $query->update(
353
            $this->dbHandler->quoteTable('ezcobj_state_link')
354
        )->set(
355
            $this->dbHandler->quoteColumn('contentobject_state_id'),
356
            $query->bindValue($newStateId, null, \PDO::PARAM_INT)
357
        )->where(
358
            $query->expr->eq(
359
                $this->dbHandler->quoteColumn('contentobject_state_id'),
360
                $query->bindValue($oldStateId, null, \PDO::PARAM_INT)
361
            )
362
        );
363
364
        $query->prepare()->execute();
365
    }
366
367
    /**
368
     * Deletes object state links identified by $stateId.
@@ 642-658 (lines=17) @@
639
     * @param mixed $stateId
640
     * @param int $priority
641
     */
642
    public function updateObjectStatePriority($stateId, $priority)
643
    {
644
        $query = $this->dbHandler->createUpdateQuery();
645
        $query->update(
646
            $this->dbHandler->quoteTable('ezcobj_state')
647
        )->set(
648
            $this->dbHandler->quoteColumn('priority'),
649
            $query->bindValue($priority, null, \PDO::PARAM_INT)
650
        )->where(
651
            $query->expr->eq(
652
                $this->dbHandler->quoteColumn('id'),
653
                $query->bindValue($stateId, null, \PDO::PARAM_INT)
654
            )
655
        );
656
657
        $query->prepare()->execute();
658
    }
659
660
    /**
661
     * Creates a generalized query for fetching object state(s).

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

@@ 1187-1205 (lines=19) @@
1184
     *
1185
     * @return int[]
1186
     */
1187
    public function listVersionNumbers($contentId)
1188
    {
1189
        $query = $this->dbHandler->createSelectQuery();
1190
        $query->selectDistinct(
1191
            $this->dbHandler->quoteColumn('version')
1192
        )->from(
1193
            $this->dbHandler->quoteTable('ezcontentobject_version')
1194
        )->where(
1195
            $query->expr->eq(
1196
                $this->dbHandler->quoteColumn('contentobject_id'),
1197
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
1198
            )
1199
        );
1200
1201
        $statement = $query->prepare();
1202
        $statement->execute();
1203
1204
        return $statement->fetchAll(\PDO::FETCH_COLUMN);
1205
    }
1206
1207
    /**
1208
     * Returns last version number for content identified by $contentId.
@@ 1241-1259 (lines=19) @@
1238
     *
1239
     * @return int[]
1240
     */
1241
    public function getAllLocationIds($contentId)
1242
    {
1243
        $query = $this->dbHandler->createSelectQuery();
1244
        $query->select(
1245
            $this->dbHandler->quoteColumn('node_id')
1246
        )->from(
1247
            $this->dbHandler->quoteTable('ezcontentobject_tree')
1248
        )->where(
1249
            $query->expr->eq(
1250
                $this->dbHandler->quoteColumn('contentobject_id'),
1251
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
1252
            )
1253
        );
1254
1255
        $statement = $query->prepare();
1256
        $statement->execute();
1257
1258
        return $statement->fetchAll(\PDO::FETCH_COLUMN);
1259
    }
1260
1261
    /**
1262
     * Returns all field IDs of $contentId grouped by their type.
@@ 1994-2011 (lines=18) @@
1991
     *
1992
     * @return int[]
1993
     */
1994
    public function getContentIdsByContentTypeId($contentTypeId)
1995
    {
1996
        $query = $this->dbHandler->createSelectQuery();
1997
        $query
1998
            ->select($this->dbHandler->quoteColumn('id'))
1999
            ->from($this->dbHandler->quoteTable('ezcontentobject'))
2000
            ->where(
2001
                $query->expr->eq(
2002
                    $this->dbHandler->quoteColumn('contentclass_id'),
2003
                    $query->bindValue($contentTypeId, null, PDO::PARAM_INT)
2004
                )
2005
            );
2006
2007
        $statement = $query->prepare();
2008
        $statement->execute();
2009
2010
        return $statement->fetchAll(PDO::FETCH_COLUMN);
2011
    }
2012
2013
    /**
2014
     * Load name data for set of content id's and corresponding version number.

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

@@ 329-347 (lines=19) @@
326
     * @param mixed $contentId
327
     * @param mixed $roleId
328
     */
329
    public function removeRole($contentId, $roleId)
330
    {
331
        $query = $this->handler->createDeleteQuery();
332
        $query
333
            ->deleteFrom($this->handler->quoteTable('ezuser_role'))
334
            ->where(
335
                $query->expr->lAnd(
336
                    $query->expr->eq(
337
                        $this->handler->quoteColumn('contentobject_id'),
338
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
339
                    ),
340
                    $query->expr->eq(
341
                        $this->handler->quoteColumn('role_id'),
342
                        $query->bindValue($roleId, null, \PDO::PARAM_INT)
343
                    )
344
                )
345
            );
346
        $query->prepare()->execute();
347
    }
348
349
    /**
350
     * Remove role from user or user group, by assignment ID.