private function deleteTranslationFromContentVersions($contentId, $languageId, $versionNo = null)
    {
        $query = $this->connection->createQueryBuilder();
        $query->update('ezcontentobject_version')
            // parameter for bitwise operation has to be placed verbatim (w/o binding) for this to work cross-DBMS
            ->set('language_mask', 'language_mask & ~ ' . $languageId)
            ->set('modified', ':now')
            // update initial_language_id only if it matches removed translation languageId
            ->set(
                'initial_language_id',
                'CASE WHEN initial_language_id = :languageId ' .
                'THEN (SELECT initial_language_id AS main_language_id FROM ezcontentobject c WHERE c.id = :contentId) ' .
                'ELSE initial_language_id END'
            )
            ->where('contentobject_id = :contentId')
            ->andWhere(
            // make sure removed translation is not the last one (incl. alwaysAvailable)
                $query->expr()->andX(
                    'language_mask & ~ ' . $languageId . ' <> 0',
                    'language_mask & ~ ' . $languageId . ' <> 1'
                )
            )
            ->setParameter(':now', time())
            ->setParameter(':contentId', $contentId)
            ->setParameter(':languageId', $languageId)
        ;

        if (null !== $versionNo) {
            $query
                ->andWhere('version = :versionNo')
                ->setParameter(':versionNo', $versionNo)
            ;
        }

        $rowCount = $query->execute();

        // no rows updated means that most likely somehow it was the last remaining translation
        if ($rowCount === 0) {
            throw new BadStateException(
                '$languageCode',
                'Specified translation is the only one Content Object Version has'
            );
        }
    }
private function deleteTranslationFromContentVersions($contentId, $languageId, $versionNo = null)
    {
        $query = $this->connection->createQueryBuilder();
        $query->update('ezcontentobject_version')
            // parameter for bitwise operation has to be placed verbatim (w/o binding) for this to work cross-DBMS
            ->set('language_mask', 'language_mask & ~ ' . $languageId)
            ->set('modified', ':now')
            // update initial_language_id only if it matches removed translation languageId
            ->set(
                'initial_language_id',
                'CASE WHEN initial_language_id = :languageId ' .
                'THEN (SELECT initial_language_id AS main_language_id FROM ezcontentobject c WHERE c.id = :contentId) ' .
                'ELSE initial_language_id END'
            )
            ->where('contentobject_id = :contentId')
            ->andWhere(
            // make sure removed translation is not the last one (incl. alwaysAvailable)
                $query->expr()->andX(
                    'language_mask & ~ ' . $languageId . ' <> 0',
                    'language_mask & ~ ' . $languageId . ' <> 1'
                )
            )
            ->setParameter(':now', time())
            ->setParameter(':contentId', $contentId)
            ->setParameter(':languageId', $languageId)
        ;

        if (null !== $versionNo) {
            $query
                ->andWhere('version = :versionNo')
                ->setParameter(':versionNo', $versionNo)
            ;
        }

        $rowCount = $query->execute();

        // no rows updated means that most likely somehow it was the last remaining translation
        if ($rowCount === 0) {
            throw new BadStateException(
                '$languageCode',
                'Specified translation is the only one Content Object Version has'
            );
        }
    }
private function deleteTranslationFromContentVersions ( $ contentId , $ languageId , $ versionNo = null ) { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ezcontentobject_version' ) // parameter for bitwise operation has to be placed verbatim (w/o binding) for this to work cross-DBMS -> set ( 'language_mask' , 'language_mask & ~ ' . $ languageId ) -> set ( 'modified' , ':now' ) // update initial_language_id only if it matches removed translation languageId -> set ( 'initial_language_id' , 'CASE WHEN initial_language_id = :languageId ' . 'THEN (SELECT initial_language_id AS main_language_id FROM ezcontentobject c WHERE c.id = :contentId) ' . 'ELSE initial_language_id END' ) -> where ( 'contentobject_id = :contentId' ) -> andWhere ( // make sure removed translation is not the last one (incl. alwaysAvailable) $ query -> expr ( ) -> andX ( 'language_mask & ~ ' . $ languageId . ' <> 0' , 'language_mask & ~ ' . $ languageId . ' <> 1' ) ) -> setParameter ( ':now' , time ( ) ) -> setParameter ( ':contentId' , $ contentId ) -> setParameter ( ':languageId' , $ languageId ) ; if ( null !== $ versionNo ) { $ query -> andWhere ( 'version = :versionNo' ) -> setParameter ( ':versionNo' , $ versionNo ) ; } $ rowCount = $ query -> execute ( ) ; // no rows updated means that most likely somehow it was the last remaining translation if ( $ rowCount === 0 ) { throw new BadStateException ( '$languageCode' , 'Specified translation is the only one Content Object Version has' ) ; } }
Remove language from language_mask of ezcontentobject_version and update initialLanguageId
if it matches the removed one.

@param int $contentId
@param int $languageId
@param int $versionNo optional, if specified, apply to this Version only.
@throws \eZ\Publish\Core\Base\Exceptions\BadStateException
Remove language from language_mask of ezcontentobject_version and update initialLanguageId if it matches the removed one .