Resetting all multi-language fields with specific language id
to default value in all tables. Only if language ID > 0.

@param int $langId Language id

@return null
321689
public function resetLanguage($langId)
    {
        if ((int) $langId === 0) {
            return;
        }

        $tables = $this->getAllTables();

        // removing tables which does not requires reset
        foreach ($this->_aSkipTablesOnReset as $skipTable) {
            if (($skipId = array_search($skipTable, $tables)) !== false) {
                unset($tables[$skipId]);
            }
        }

        foreach ($tables as $tableName) {
            $this->resetMultilangFields($langId, $tableName);
        }
    }
1329391
protected function initLanguages()
    {
        $this->languageIdList[0] = 0;

        $query      = 'SELECT uid
                         FROM sys_language
                        WHERE hidden = 0';
        $langIdList = DatabaseUtility::getColWithIndex($query);

        $this->languageIdList = $langIdList;
    }
513620
protected function _resetMultiLangDbFields($iLangId)
    {
        $iLangId = (int) $iLangId;

        //skipping reseting language with id = 0
        if ($iLangId) {
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction();

            try {
                $oDbMeta = oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class);
                $oDbMeta->resetLanguage($iLangId);

                \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
            } catch (Exception $oEx) {
                // if exception, rollBack everything
                \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->rollbackTransaction();

                //show warning
                $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\ExceptionToDisplay::class);
                $oEx->setMessage('LANGUAGE_ERROR_RESETING_MULTILANG_FIELDS');
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($oEx);
            }
        }
    }
273710
public function deleteTranslationFromContent($contentId, $languageCode)
    {
        $language = $this->languageHandler->loadByLanguageCode($languageCode);

        $this->connection->beginTransaction();
        try {
            $this->deleteTranslationFromContentVersions($contentId, $language->id);
            $this->deleteTranslationFromContentNames($contentId, $languageCode);
            $this->deleteTranslationFromContentObject($contentId, $language->id);

            $this->connection->commit();
        } catch (DBALException $e) {
            $this->connection->rollBack();
            throw $e;
        }
    }
641668
public function actionSave($id = null, $languageId)
    {
        if (!empty($languageId)) {
            if (!empty($id)) {

                $model = $this->findModel($id);
                if (empty($model)) {
                    throw new NotFoundHttpException;
                }
                $modelTranslation = $this->findModelTranslation($id, $languageId);
                if (empty($modelTranslation)) {
                    $modelTranslation = new DeliveryMethodTranslation();
                }
            }
            else {
                $model = new DeliveryMethod();
                $modelTranslation = new DeliveryMethodTranslation();
            }
        }
        else throw new BadRequestHttpException();


        if ($model->load(Yii::$app->request->post()) && $modelTranslation->load(Yii::$app->request->post())) {

            $model->logo = UploadedFile::getInstance($model, 'logo');
            if (!empty($model->logo)) {

                $uploadedImageName = $model->upload();

                $model->image_name = $uploadedImageName;
            }
            $model->save(false);

            $modelTranslation->delivery_method_id = $model->id;
            $modelTranslation->language_id = $languageId;
            if ($modelTranslation->validate()) {

                $modelTranslation->save();
                return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]);
            }
        }
        return $this->render('save', [
            'model' => $model,
            'modelTranslation' => $modelTranslation,
            'languages' => Language::find()->all(),
            'selectedLanguage' => Language::findOne($languageId)
        ]);

    }
1046640
protected function setDefault(int $localeId): void
	{
		$this->orm->locales->getById($localeId)->setDefault();
	}
19786
public static function reset($lang = null)
    {
        if (is_string($lang)) {
            unset(static::$_singular[$lang]);
            unset(static::$_plural[$lang]);
            return;
        }
        static::$_singular = [];
        static::$_plural = [];

        if ($lang === true) {
            return;
        }

        /**
         * Initilalize the class with english inflector rules.
         */
        Inflector::singular('/([^s])s$/i', '\1', 'default');
        Inflector::plural('/([^s])$/i', '\1s', 'default');

        Inflector::singular('/(x|z|s|ss|ch|sh)es$/i', '\1', 'default');
        Inflector::plural('/(x|z|ss|ch|sh)$/i', '\1es', 'default');

        Inflector::singular('/ies$/i', 'y', 'default');
        Inflector::plural('/([^aeiouy]|qu)y$/i', '\1ies', 'default');

        Inflector::plural('/(meta|data)$/i', '\1', 'default');

        Inflector::irregular('child', 'children', 'default');
        Inflector::irregular('equipment', 'equipment', 'default');
        Inflector::irregular('information', 'information', 'default');
        Inflector::irregular('man', 'men', 'default');
        Inflector::irregular('news', 'news', 'default');
        Inflector::irregular('person', 'people', 'default');
        Inflector::irregular('woman', 'women', 'default');

        /**
         * Warning, using an "exhastive" list of rules will slow
         * down all singularizations/pluralizations generations.
         * So it may be preferable to only add the ones you are actually needed.
         *
         * Anyhow bellow a list english exceptions which are not covered by the above rules.
         */
        // Inflector::irregular('advice', 'advice', 'default');
        // Inflector::irregular('aircraft', 'aircraft', 'default');
        // Inflector::irregular('alias', 'aliases', 'default');
        // Inflector::irregular('alga', 'algae', 'default');
        // Inflector::irregular('alumna', 'alumnae', 'default');
        // Inflector::irregular('alumnus', 'alumni', 'default');
        // Inflector::irregular('analysis', 'analyses', 'default');
        // Inflector::irregular('antenna', 'antennae', 'default');
        // Inflector::irregular('automaton', 'automata', 'default');
        // Inflector::irregular('axis', 'axes', 'default');
        // Inflector::irregular('bacillus', 'bacilli', 'default');
        // Inflector::irregular('bacterium', 'bacteria', 'default');
        // Inflector::irregular('barracks', 'barracks', 'default');
        // Inflector::irregular('basis', 'bases', 'default');
        // Inflector::irregular('bellows', 'bellows', 'default');
        // Inflector::irregular('buffalo', 'buffaloes', 'default');
        // Inflector::irregular('bus', 'buses', 'default');
        // Inflector::irregular('bison', 'bison', 'default');
        // Inflector::irregular('cactus', 'cacti', 'default');
        // Inflector::irregular('cafe', 'cafes', 'default');
        // Inflector::irregular('calf', 'calves', 'default');
        // Inflector::irregular('cargo', 'cargoes', 'default');
        // Inflector::irregular('cattle', 'cattle', 'default');
        // Inflector::irregular('child', 'children', 'default');
        // Inflector::irregular('congratulations', 'congratulations', 'default');
        // Inflector::irregular('corn', 'corn', 'default');
        // Inflector::irregular('crisis', 'crises', 'default');
        // Inflector::irregular('criteria', 'criterion', 'default');
        // Inflector::irregular('curriculum', 'curricula', 'default');
        // Inflector::irregular('datum', 'data', 'default');
        // Inflector::irregular('deer', 'deer', 'default');
        // Inflector::irregular('die', 'dice', 'default');
        // Inflector::irregular('dregs', 'dregs', 'default');
        // Inflector::irregular('duck', 'duck', 'default');
        // Inflector::irregular('echo', 'echos', 'default');
        // Inflector::irregular('elf', 'elves', 'default');
        // Inflector::irregular('ellipsis', 'ellipses', 'default');
        // Inflector::irregular('embargo', 'embargoes', 'default');
        // Inflector::irregular('equipment', 'equipment', 'default');
        // Inflector::irregular('erratum', 'errata', 'default');
        // Inflector::irregular('evidence', 'evidence', 'default');
        // Inflector::irregular('eyeglasses', 'eyeglasses', 'default');
        // Inflector::irregular('fish', 'fish', 'default');
        // Inflector::irregular('focus', 'foci', 'default');
        // Inflector::irregular('foot', 'feet', 'default');
        // Inflector::irregular('fungus', 'fungi', 'default');
        // Inflector::irregular('gallows', 'gallows', 'default');
        // Inflector::irregular('genus', 'genera', 'default');
        // Inflector::irregular('goose', 'geese', 'default');
        // Inflector::irregular('gold', 'gold', 'default');
        // Inflector::irregular('grotto', 'grottoes', 'default');
        // Inflector::irregular('gymnasium', 'gymnasia', 'default');
        // Inflector::irregular('half', 'halves', 'default');
        // Inflector::irregular('headquarters', 'headquarters', 'default');
        // Inflector::irregular('hoof', 'hooves', 'default');
        // Inflector::irregular('hypothesis', 'hypotheses', 'default');
        // Inflector::irregular('information', 'information', 'default');
        // Inflector::irregular('graffito', 'graffiti', 'default');
        // Inflector::irregular('half', 'halves', 'default');
        // Inflector::irregular('hero', 'heroes', 'default');
        // Inflector::irregular('jewelry', 'jewelry', 'default');
        // Inflector::irregular('kin', 'kin', 'default');
        // Inflector::irregular('knife', 'knives', 'default');
        // Inflector::irregular('larva', 'larvae', 'default');
        // Inflector::irregular('leaf', 'leaves', 'default');
        // Inflector::irregular('legislation', 'legislation', 'default');
        // Inflector::irregular('life', 'lives', 'default');
        // Inflector::irregular('loaf', 'loaves', 'default');
        // Inflector::irregular('locus', 'loci', 'default');
        // Inflector::irregular('louse', 'lice', 'default');
        // Inflector::irregular('luck', 'luck', 'default');
        // Inflector::irregular('luggage', 'luggage', 'default');
        // Inflector::irregular('man', 'men', 'default');
        // Inflector::irregular('mathematics', 'mathematics', 'default');
        // Inflector::irregular('matrix', 'matrices', 'default');
        // Inflector::irregular('means', 'means', 'default');
        // Inflector::irregular('measles', 'measles', 'default');
        // Inflector::irregular('medium', 'media', 'default');
        // Inflector::irregular('memorandum', 'memoranda', 'default');
        // Inflector::irregular('money', 'monies', 'default');
        // Inflector::irregular('moose', 'moose', 'default');
        // Inflector::irregular('mosquito', 'mosquitoes', 'default');
        // Inflector::irregular('motto', 'mottoes', 'default');
        // Inflector::irregular('mouse', 'mice', 'default');
        // Inflector::irregular('mumps', 'mumps', 'default');
        // Inflector::irregular('music', 'music', 'default');
        // Inflector::irregular('mythos', 'mythoi', 'default');
        // Inflector::irregular('nebula', 'nebulae', 'default');
        // Inflector::irregular('neurosis', 'neuroses', 'default');
        // Inflector::irregular('news', 'news', 'default');
        // Inflector::irregular('nucleus', 'nuclei', 'default');
        // Inflector::irregular('numen', 'numina', 'default');
        // Inflector::irregular('oasis', 'oases', 'default');
        // Inflector::irregular('oats', 'oats', 'default');
        // Inflector::irregular('octopus', 'octopuses', 'default');
        // Inflector::irregular('offspring', 'offspring', 'default');
        // Inflector::irregular('ovum', 'ova', 'default');
        // Inflector::irregular('ox', 'oxen', 'default');
        // Inflector::irregular('pajamas', 'pajamas', 'default');
        // Inflector::irregular('pants', 'pants', 'default');
        // Inflector::irregular('paralysis', 'paralyses', 'default');
        // Inflector::irregular('parenthesis', 'parentheses', 'default');
        // Inflector::irregular('person', 'people', 'default');
        // Inflector::irregular('phenomenon', 'phenomena', 'default');
        // Inflector::irregular('pike', 'pike', 'default');
        // Inflector::irregular('plankton', 'plankton', 'default');
        // Inflector::irregular('pliers', 'pliers', 'default');
        // Inflector::irregular('polyhedron', 'polyhedra', 'default');
        // Inflector::irregular('potato', 'potatoes', 'default');
        // Inflector::irregular('quiz', 'quizzes', 'default');
        // Inflector::irregular('radius', 'radii', 'default');
        // Inflector::irregular('roof', 'roofs', 'default');
        // Inflector::irregular('salmon', 'salmon', 'default');
        // Inflector::irregular('scarf', 'scarves', 'default');
        // Inflector::irregular('scissors', 'scissors', 'default');
        // Inflector::irregular('self', 'selves', 'default');
        // Inflector::irregular('series', 'series', 'default');
        // Inflector::irregular('shears', 'shears', 'default');
        // Inflector::irregular('sheep', 'sheep', 'default');
        // Inflector::irregular('shelf', 'shelves', 'default');
        // Inflector::irregular('shorts', 'shorts', 'default');
        // Inflector::irregular('silver', 'silver', 'default');
        // Inflector::irregular('species', 'species', 'default');
        // Inflector::irregular('squid', 'squid', 'default');
        // Inflector::irregular('stimulus', 'stimuli', 'default');
        // Inflector::irregular('stratum', 'strata', 'default');
        // Inflector::irregular('swine', 'swine', 'default');
        // Inflector::irregular('syllabus', 'syllabi', 'default');
        // Inflector::irregular('synopsis', 'synopses', 'default');
        // Inflector::irregular('synthesis', 'syntheses', 'default');
        // Inflector::irregular('tax', 'taxes', 'default');
        // Inflector::irregular('terminus', 'termini', 'default');
        // Inflector::irregular('thesis', 'theses', 'default');
        // Inflector::irregular('thief', 'thieves', 'default');
        // Inflector::irregular('tomato', 'tomatoes', 'default');
        // Inflector::irregular('tongs', 'tongs', 'default');
        // Inflector::irregular('tooth', 'teeth', 'default');
        // Inflector::irregular('torpedo', 'torpedoes', 'default');
        // Inflector::irregular('torus', 'tori', 'default');
        // Inflector::irregular('trousers', 'trousers', 'default');
        // Inflector::irregular('trout', 'trout', 'default');
        // Inflector::irregular('tweezers', 'tweezers', 'default');
        // Inflector::irregular('vertebra', 'vertebrae', 'default');
        // Inflector::irregular('vertex', 'vertices', 'default');
        // Inflector::irregular('vespers', 'vespers', 'default');
        // Inflector::irregular('veto', 'vetoes', 'default');
        // Inflector::irregular('volcano', 'volcanoes', 'default');
        // Inflector::irregular('vortex', 'vortices', 'default');
        // Inflector::irregular('vita', 'vitae', 'default');
        // Inflector::irregular('virus', 'viri', 'default');
        // Inflector::irregular('wheat', 'wheat', 'default');
        // Inflector::irregular('wife', 'wives', 'default');
        // Inflector::irregular('wolf', 'wolves', 'default');
        // Inflector::irregular('woman', 'women', 'default');
        // Inflector::irregular('zero', 'zeros', 'default');
    }
1005252
public function find($id, $lang = null)
  {
    $results = $this->client->request([
      'ids' => $id,
      'languages' => $lang
    ]);

    if($results->isEmpty()) {
      return null;
    }

    return $results->first();
  }
11098
public function deleteLanguage($id)
    {
        try {
            return $this->innerGateway->deleteLanguage($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
907562
public function actionEditLanguage($id = null, $contextId = null)
    {
        if ($id === null) {
            $model = new Language();
        } else {
            $model = $this->findLanguageModel($id);
        }
        if ($contextId !== null) {
            $model->context_id = $contextId;
        }
        $hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-language'))
            || (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-language'));
        $isLoaded = $model->load(Yii::$app->request->post());
        if ($isLoaded && !$hasAccess) {
            throw new ForbiddenHttpException;
        }
        if ($isLoaded && $model->save()) {
            return $this->redirect(['edit-language', 'id' => $model->id]);
        } else {
            return $this->render(
                'edit-language',
                [
                    'hasAccess' => $hasAccess,
                    'model' => $model,
                ]
            );
        }
    }
944050
public function delete($lang, $id)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Permissions', 'delete')) {
            return $this->noPermission();
        }

        DB::statement('SET FOREIGN_KEY_CHECKS=0');
        $group = \App\Models\UserGroup::find($id)->delete();
        if($group) {
            DB::table('permissions')->where('groupID', $id)->delete();
            $result = $this->response('Group is deleted');
        }else{
            $result = $this->response('Internal server error. Please try again later', 500);
        }
        return $result;
    }
1153112
public function setLanguage($lang = null)
    {
        $this->_iLanguage = (int) $lang;
        // reset
        $this->_sViewTable = false;
    }
888125
public function lookupLocaleForLanguageId($languageId)
    {
        /** @var Model $languageModel */
        $languageModel = static::$cmsLanguageModel;

        $language = $languageModel::where('id', $languageId)
            ->remember((config('pxlcms.cache.languages', 15)))
            ->first();

        if (empty($language)) return null;

        return $this->normalizeToLocale($language->code);
    }
1206515
protected function findOrCreateModelTranslation($id, $languageId)
    {
        $modelTranslations = OrderStatusTranslation::find()
            ->where(['order_status_id' => $id, 'language_id' => $languageId])->one();
        return (!empty($modelTranslations)) ? $modelTranslations : new OrderStatusTranslation();
    }
509389
public function deleteMenu($lang, $menuID)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Menu', 'delete')) {
            return $this->noPermission();
        }

        $menu = Menu::find($menuID);
        if(!$menu) {
            return $this->response("Menu doesn't exist", 400);
        }

        if(!$menu->isPrimary) {
            $menuLinks = MenuLink::where('menuID', $menuID);
            $menuLinks->delete();
            $menu->delete();
            return $this->response("Menu deleted", 200, Menu::getPrimaryMenuID());
        }else{
            return $this->response("Primary menu can not be deleted", 400);
        }
    }
539738
public function actionDeleteLanguage($id)
    {
        $model = $this->findLanguageModel($id);
        $model->delete();
        return $this->redirect(['edit', 'id' => $model->context_id]);
    }
433238
public function getLocaleByLangId($langId)
    {
        // Event parameters prepare
        $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());

        // Sending service start event
        $arrayParameters = $this->sendEvent('melisengine_service_get_local_by_id_start', $arrayParameters);

        // Service implementation start
        $langTable = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
        $result = $langTable->getEntryByField('lang_cms_id', $langId)->toArray();
        if(!isset($result[0]['lang_cms_locale'])) return null;
        $result = $result[0]['lang_cms_locale'];
        // Service implementation end

        // Adding results to parameters for events treatment if needed
        $arrayParameters['results'] = $result;
        // Sending service end event
        $arrayParameters = $this->sendEvent('melisengine_service_get_local_by_id_end', $arrayParameters);

        return $arrayParameters['results'];
    }