Code Duplication    Length = 23-30 lines in 6 locations

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

@@ 458-480 (lines=23) @@
455
     * @param mixed $typeId
456
     * @param int $status
457
     */
458
    public function deleteGroupAssignment($groupId, $typeId, $status)
459
    {
460
        $q = $this->dbHandler->createDeleteQuery();
461
        $q->deleteFrom(
462
            $this->dbHandler->quoteTable('ezcontentclass_classgroup')
463
        )->where(
464
            $q->expr->lAnd(
465
                $q->expr->eq(
466
                    $this->dbHandler->quoteColumn('contentclass_id'),
467
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
468
                ),
469
                $q->expr->eq(
470
                    $this->dbHandler->quoteColumn('contentclass_version'),
471
                    $q->bindValue($status, null, \PDO::PARAM_INT)
472
                ),
473
                $q->expr->eq(
474
                    $this->dbHandler->quoteColumn('group_id'),
475
                    $q->bindValue($groupId, null, \PDO::PARAM_INT)
476
                )
477
            )
478
        );
479
        $q->prepare()->execute();
480
    }
481
482
    /**
483
     * Loads data about Groups with $groupIds.
@@ 765-789 (lines=25) @@
762
     * @param int $status
763
     * @param mixed $fieldDefinitionId
764
     */
765
    public function deleteFieldDefinition($typeId, $status, $fieldDefinitionId)
766
    {
767
        $q = $this->dbHandler->createDeleteQuery();
768
        $q->deleteFrom(
769
            $this->dbHandler->quoteTable('ezcontentclass_attribute')
770
        )->where(
771
            $q->expr->lAnd(
772
                $q->expr->eq(
773
                    $this->dbHandler->quoteColumn('id'),
774
                    $q->bindValue($fieldDefinitionId, null, \PDO::PARAM_INT)
775
                ),
776
                $q->expr->eq(
777
                    $this->dbHandler->quoteColumn('version'),
778
                    $q->bindValue($status, null, \PDO::PARAM_INT)
779
                ),
780
                // @todo FIXME: Actually not needed
781
                $q->expr->eq(
782
                    $this->dbHandler->quoteColumn('contentclass_id'),
783
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
784
                )
785
            )
786
        );
787
788
        $q->prepare()->execute();
789
    }
790
791
    /**
792
     * Updates a $fieldDefinition for $typeId.
@@ 799-827 (lines=29) @@
796
     * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDefinition
797
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageFieldDef
798
     */
799
    public function updateFieldDefinition(
800
        $typeId,
801
        $status,
802
        FieldDefinition $fieldDefinition,
803
        StorageFieldDefinition $storageFieldDef
804
    ) {
805
        $q = $this->dbHandler->createUpdateQuery();
806
        $q
807
            ->update(
808
                $this->dbHandler->quoteTable('ezcontentclass_attribute')
809
            )->where(
810
                $q->expr->eq(
811
                    $this->dbHandler->quoteColumn('id'),
812
                    $q->bindValue($fieldDefinition->id, null, \PDO::PARAM_INT)
813
                ),
814
                $q->expr->eq(
815
                    $this->dbHandler->quoteColumn('version'),
816
                    $q->bindValue($status, null, \PDO::PARAM_INT)
817
                ),
818
                // @todo FIXME: Actually not needed
819
                $q->expr->eq(
820
                    $this->dbHandler->quoteColumn('contentclass_id'),
821
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
822
                )
823
            );
824
        $this->setCommonFieldColumns($q, $fieldDefinition, $storageFieldDef);
825
826
        $q->prepare()->execute();
827
    }
828
829
    /**
830
     * Deletes all name data for $typeId in $typeStatus.

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

@@ 537-560 (lines=24) @@
534
     * @param mixed $oldParentId
535
     * @param mixed $newParentId
536
     */
537
    public function reparent($oldParentId, $newParentId)
538
    {
539
        /** @var $query \eZ\Publish\Core\Persistence\Database\UpdateQuery */
540
        $query = $this->dbHandler->createUpdateQuery();
541
        $query->update(
542
            $this->dbHandler->quoteTable($this->table)
543
        )->set(
544
            $this->dbHandler->quoteColumn('parent'),
545
            $query->bindValue($newParentId, null, \PDO::PARAM_INT)
546
        )->where(
547
            $query->expr->lAnd(
548
                $query->expr->eq(
549
                    $this->dbHandler->quoteColumn('is_alias'),
550
                    $query->bindValue(0, null, \PDO::PARAM_INT)
551
                ),
552
                $query->expr->eq(
553
                    $this->dbHandler->quoteColumn('parent'),
554
                    $query->bindValue($oldParentId, null, \PDO::PARAM_INT)
555
                )
556
            )
557
        );
558
559
        $query->prepare()->execute();
560
    }
561
562
    /**
563
     * Updates single row data matched by composite primary key.
@@ 1013-1039 (lines=27) @@
1010
     *
1011
     * @return bool
1012
     */
1013
    public function removeCustomAlias($parentId, $textMD5)
1014
    {
1015
        /** @var $query \eZ\Publish\Core\Persistence\Database\DeleteQuery */
1016
        $query = $this->dbHandler->createDeleteQuery();
1017
        $query->deleteFrom(
1018
            $this->dbHandler->quoteTable($this->table)
1019
        )->where(
1020
            $query->expr->lAnd(
1021
                $query->expr->eq(
1022
                    $this->dbHandler->quoteColumn('parent'),
1023
                    $query->bindValue($parentId, null, \PDO::PARAM_INT)
1024
                ),
1025
                $query->expr->eq(
1026
                    $this->dbHandler->quoteColumn('text_md5'),
1027
                    $query->bindValue($textMD5, null, \PDO::PARAM_STR)
1028
                ),
1029
                $query->expr->eq(
1030
                    $this->dbHandler->quoteColumn('is_alias'),
1031
                    $query->bindValue(1, null, \PDO::PARAM_INT)
1032
                )
1033
            )
1034
        );
1035
        $statement = $query->prepare();
1036
        $statement->execute();
1037
1038
        return $statement->rowCount() === 1 ?: false;
1039
    }
1040
1041
    /**
1042
     * Deletes all rows with given $action and optionally $id.
@@ 1051-1080 (lines=30) @@
1048
     *
1049
     * @return bool
1050
     */
1051
    public function remove($action, $id = null)
1052
    {
1053
        /** @var $query \eZ\Publish\Core\Persistence\Database\DeleteQuery */
1054
        $query = $this->dbHandler->createDeleteQuery();
1055
        $query->deleteFrom(
1056
            $this->dbHandler->quoteTable($this->table)
1057
        )->where(
1058
            $query->expr->eq(
1059
                $this->dbHandler->quoteColumn('action'),
1060
                $query->bindValue($action, null, \PDO::PARAM_STR)
1061
            )
1062
        );
1063
1064
        if ($id !== null) {
1065
            $query->where(
1066
                $query->expr->lAnd(
1067
                    $query->expr->eq(
1068
                        $this->dbHandler->quoteColumn('is_alias'),
1069
                        $query->bindValue(0, null, \PDO::PARAM_INT)
1070
                    ),
1071
                    $query->expr->eq(
1072
                        $this->dbHandler->quoteColumn('id'),
1073
                        $query->bindValue($id, null, \PDO::PARAM_INT)
1074
                    )
1075
                )
1076
            );
1077
        }
1078
1079
        $query->prepare()->execute();
1080
    }
1081
1082
    /**
1083
     * Loads all autogenerated entries with given $parentId with optionally included history entries.