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/User/Gateway/DoctrineDatabase.php 1 location

@@ 449-467 (lines=19) @@
446
     * @param mixed $contentId
447
     * @param mixed $roleId
448
     */
449
    public function removeRole($contentId, $roleId)
450
    {
451
        $query = $this->handler->createDeleteQuery();
452
        $query
453
            ->deleteFrom($this->handler->quoteTable('ezuser_role'))
454
            ->where(
455
                $query->expr->lAnd(
456
                    $query->expr->eq(
457
                        $this->handler->quoteColumn('contentobject_id'),
458
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
459
                    ),
460
                    $query->expr->eq(
461
                        $this->handler->quoteColumn('role_id'),
462
                        $query->bindValue($roleId, null, \PDO::PARAM_INT)
463
                    )
464
                )
465
            );
466
        $query->prepare()->execute();
467
    }
468
469
    /**
470
     * Remove role from user or user group, by assignment ID.

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

@@ 1255-1273 (lines=19) @@
1252
     *
1253
     * @return int[]
1254
     */
1255
    public function listVersionNumbers($contentId)
1256
    {
1257
        $query = $this->dbHandler->createSelectQuery();
1258
        $query->selectDistinct(
1259
            $this->dbHandler->quoteColumn('version')
1260
        )->from(
1261
            $this->dbHandler->quoteTable('ezcontentobject_version')
1262
        )->where(
1263
            $query->expr->eq(
1264
                $this->dbHandler->quoteColumn('contentobject_id'),
1265
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
1266
            )
1267
        );
1268
1269
        $statement = $query->prepare();
1270
        $statement->execute();
1271
1272
        return $statement->fetchAll(\PDO::FETCH_COLUMN);
1273
    }
1274
1275
    /**
1276
     * Returns last version number for content identified by $contentId.
@@ 1309-1327 (lines=19) @@
1306
     *
1307
     * @return int[]
1308
     */
1309
    public function getAllLocationIds($contentId)
1310
    {
1311
        $query = $this->dbHandler->createSelectQuery();
1312
        $query->select(
1313
            $this->dbHandler->quoteColumn('node_id')
1314
        )->from(
1315
            $this->dbHandler->quoteTable('ezcontentobject_tree')
1316
        )->where(
1317
            $query->expr->eq(
1318
                $this->dbHandler->quoteColumn('contentobject_id'),
1319
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
1320
            )
1321
        );
1322
1323
        $statement = $query->prepare();
1324
        $statement->execute();
1325
1326
        return $statement->fetchAll(\PDO::FETCH_COLUMN);
1327
    }
1328
1329
    /**
1330
     * Returns all field IDs of $contentId grouped by their type.
@@ 2062-2079 (lines=18) @@
2059
     *
2060
     * @return int[]
2061
     */
2062
    public function getContentIdsByContentTypeId($contentTypeId)
2063
    {
2064
        $query = $this->dbHandler->createSelectQuery();
2065
        $query
2066
            ->select($this->dbHandler->quoteColumn('id'))
2067
            ->from($this->dbHandler->quoteTable('ezcontentobject'))
2068
            ->where(
2069
                $query->expr->eq(
2070
                    $this->dbHandler->quoteColumn('contentclass_id'),
2071
                    $query->bindValue($contentTypeId, null, PDO::PARAM_INT)
2072
                )
2073
            );
2074
2075
        $statement = $query->prepare();
2076
        $statement->execute();
2077
2078
        return $statement->fetchAll(PDO::FETCH_COLUMN);
2079
    }
2080
2081
    /**
2082
     * Load name data for set of content id's and corresponding version number.