Code Duplication    Length = 23-30 lines in 6 locations

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

@@ 446-468 (lines=23) @@
443
     * @param mixed $typeId
444
     * @param int $status
445
     */
446
    public function deleteGroupAssignment($groupId, $typeId, $status)
447
    {
448
        $q = $this->dbHandler->createDeleteQuery();
449
        $q->deleteFrom(
450
            $this->dbHandler->quoteTable('ezcontentclass_classgroup')
451
        )->where(
452
            $q->expr->lAnd(
453
                $q->expr->eq(
454
                    $this->dbHandler->quoteColumn('contentclass_id'),
455
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
456
                ),
457
                $q->expr->eq(
458
                    $this->dbHandler->quoteColumn('contentclass_version'),
459
                    $q->bindValue($status, null, \PDO::PARAM_INT)
460
                ),
461
                $q->expr->eq(
462
                    $this->dbHandler->quoteColumn('group_id'),
463
                    $q->bindValue($groupId, null, \PDO::PARAM_INT)
464
                )
465
            )
466
        );
467
        $q->prepare()->execute();
468
    }
469
470
    /**
471
     * Loads data about Group with $groupId.
@@ 756-780 (lines=25) @@
753
     * @param int $status
754
     * @param mixed $fieldDefinitionId
755
     */
756
    public function deleteFieldDefinition($typeId, $status, $fieldDefinitionId)
757
    {
758
        $q = $this->dbHandler->createDeleteQuery();
759
        $q->deleteFrom(
760
            $this->dbHandler->quoteTable('ezcontentclass_attribute')
761
        )->where(
762
            $q->expr->lAnd(
763
                $q->expr->eq(
764
                    $this->dbHandler->quoteColumn('id'),
765
                    $q->bindValue($fieldDefinitionId, null, \PDO::PARAM_INT)
766
                ),
767
                $q->expr->eq(
768
                    $this->dbHandler->quoteColumn('version'),
769
                    $q->bindValue($status, null, \PDO::PARAM_INT)
770
                ),
771
                // @todo FIXME: Actually not needed
772
                $q->expr->eq(
773
                    $this->dbHandler->quoteColumn('contentclass_id'),
774
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
775
                )
776
            )
777
        );
778
779
        $q->prepare()->execute();
780
    }
781
782
    /**
783
     * Updates a $fieldDefinition for $typeId.
@@ 790-818 (lines=29) @@
787
     * @param \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDefinition
788
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition $storageFieldDef
789
     */
790
    public function updateFieldDefinition(
791
        $typeId,
792
        $status,
793
        FieldDefinition $fieldDefinition,
794
        StorageFieldDefinition $storageFieldDef
795
    ) {
796
        $q = $this->dbHandler->createUpdateQuery();
797
        $q
798
            ->update(
799
                $this->dbHandler->quoteTable('ezcontentclass_attribute')
800
            )->where(
801
                $q->expr->eq(
802
                    $this->dbHandler->quoteColumn('id'),
803
                    $q->bindValue($fieldDefinition->id, null, \PDO::PARAM_INT)
804
                ),
805
                $q->expr->eq(
806
                    $this->dbHandler->quoteColumn('version'),
807
                    $q->bindValue($status, null, \PDO::PARAM_INT)
808
                ),
809
                // @todo FIXME: Actually not needed
810
                $q->expr->eq(
811
                    $this->dbHandler->quoteColumn('contentclass_id'),
812
                    $q->bindValue($typeId, null, \PDO::PARAM_INT)
813
                )
814
            );
815
        $this->setCommonFieldColumns($q, $fieldDefinition, $storageFieldDef);
816
817
        $q->prepare()->execute();
818
    }
819
820
    /**
821
     * Deletes all name data for $typeId in $typeStatus.

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

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