Code Duplication    Length = 37-37 lines in 2 locations

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

@@ 283-319 (lines=37) @@
280
     *
281
     * @param \eZ\Publish\SPI\Persistence\Content\ObjectState $objectState
282
     */
283
    public function updateObjectState(ObjectState $objectState)
284
    {
285
        // First update the state
286
        $query = $this->dbHandler->createUpdateQuery();
287
        $query->update(
288
            $this->dbHandler->quoteTable('ezcobj_state')
289
        )->set(
290
            $this->dbHandler->quoteColumn('default_language_id'),
291
            $query->bindValue(
292
                $this->maskGenerator->generateLanguageIndicator($objectState->defaultLanguage, false),
293
                null,
294
                \PDO::PARAM_INT
295
            )
296
        )->set(
297
            $this->dbHandler->quoteColumn('identifier'),
298
            $query->bindValue($objectState->identifier)
299
        )->set(
300
            $this->dbHandler->quoteColumn('language_mask'),
301
            $query->bindValue(
302
                $this->maskGenerator->generateLanguageMaskFromLanguageCodes($objectState->languageCodes, true),
303
                null,
304
                ParameterType::INTEGER
305
            )
306
        )->where(
307
            $query->expr->eq(
308
                $this->dbHandler->quoteColumn('id'),
309
                $query->bindValue($objectState->id, null, \PDO::PARAM_INT)
310
            )
311
        );
312
313
        $query->prepare()->execute();
314
315
        // And then refresh object state translations
316
        // by removing existing ones and adding new ones
317
        $this->deleteObjectStateTranslations($objectState->id);
318
        $this->insertObjectStateTranslations($objectState);
319
    }
320
321
    /**
322
     * Deletes object state identified by $stateId.
@@ 433-469 (lines=37) @@
430
     *
431
     * @param \eZ\Publish\SPI\Persistence\Content\ObjectState\Group $objectStateGroup
432
     */
433
    public function updateObjectStateGroup(Group $objectStateGroup)
434
    {
435
        // First update the group
436
        $query = $this->dbHandler->createUpdateQuery();
437
        $query->update(
438
            $this->dbHandler->quoteTable('ezcobj_state_group')
439
        )->set(
440
            $this->dbHandler->quoteColumn('default_language_id'),
441
            $query->bindValue(
442
                $this->maskGenerator->generateLanguageIndicator($objectStateGroup->defaultLanguage, false),
443
                null,
444
                \PDO::PARAM_INT
445
            )
446
        )->set(
447
            $this->dbHandler->quoteColumn('identifier'),
448
            $query->bindValue($objectStateGroup->identifier)
449
        )->set(
450
            $this->dbHandler->quoteColumn('language_mask'),
451
            $query->bindValue(
452
                $this->maskGenerator->generateLanguageMaskFromLanguageCodes($objectStateGroup->languageCodes, true),
453
                null,
454
                ParameterType::INTEGER
455
            )
456
        )->where(
457
            $query->expr->eq(
458
                $this->dbHandler->quoteColumn('id'),
459
                $query->bindValue($objectStateGroup->id, null, \PDO::PARAM_INT)
460
            )
461
        );
462
463
        $query->prepare()->execute();
464
465
        // And then refresh group translations
466
        // by removing old ones and adding new ones
467
        $this->deleteObjectStateGroupTranslations($objectStateGroup->id);
468
        $this->insertObjectStateGroupTranslations($objectStateGroup);
469
    }
470
471
    /**
472
     * Deletes the object state group identified by $groupId.