Helper method to get language code from store id.

@param string $store_id
Store id to convert to language code.

@return string|null
Language code if available or null.
546668
public function getLangcodeFromStoreId($store_id) {
    $mapping = $this->getStoreLanguageMapping();
    $mapping = is_array($mapping) && !empty($mapping) ? array_flip(array_filter($mapping)) : NULL;

    if (empty($store_id)) {
      return array_shift($mapping);
    }

    return !empty($mapping[$store_id]) ? $mapping[$store_id] : NULL;
  }
427265
public function getLanguageID($id)
	{
		// normalize id
		$id = $this->getCanonicalID($id);
		// remove sub tags
		if(($underscorePosition=strpos($id, '_'))!== false)
		{
			$id = substr($id, 0, $underscorePosition);
		}
		return $id;
	}
405745
public function getTranslation($item, $langcode, $store = null)
    {
        $config = $this->getConfig(null, $store);

        if (!empty($config['translation'][$langcode][$item])) {
            return $config['translation'][$langcode][$item];
        }

        if (isset($config[$item])) {
            return $config[$item];
        }

        return '';
    }
1049984
public function getStoreByStoreCode($storeCode)
    {

        // query whether or not the store with the passed store code exists
        if (isset($this->stores[$storeCode])) {
            return $this->stores[$storeCode];
        }

        // throw an exception, if not
        throw new \Exception(
            $this->appendExceptionSuffix(
                sprintf('Found invalid store code %s', $storeCode)
            )
        );
    }
491520
public function findByIdAndLocale($id, $locale)
    {
        try {
            $qb = $this->getShippingQuery($locale);
            $qb->andWhere('shipping.id = :shippingId');
            $qb->setParameter('shippingId', $id);

            return $qb->getQuery()->getSingleResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
562571
function _get_auto_id($cache_id=null, $compile_id=null) {
		if (isset($cache_id))
		return (isset($compile_id)) ? $cache_id . '|' . $compile_id  : $cache_id;
		elseif(isset($compile_id))
		return $compile_id;
		else
		return null;
	}
757557
public function encodeId($id = '')
    {
        if (empty($id)) {
            return NULL;
        }
        try {
            $hash = new Hashids($this->hashIds['salt'], $this->hashIds['minHashLength'], $this->hashIds['alphabet']);

            return $hash->encode($id);
        }
        catch (\Exception $e) {
            if (function_exists('log_message')) {
                $message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
                log_message('error', $message);
            }

            return NULL;
        }
    }
564164
protected function getListCategoryProduct($store_id)
    {
        $types = $this->category_group->getTypes();

        $categories = array();
        foreach (array_keys($types) as $type) {

            $op = array(
                'type' => $type,
                'store_id' => $store_id
            );

            $data = $this->getCategoryOptionsByStore($this->category, $this->category_group, $op);
            $categories[$type] = reset($data);
        }

        return $categories;
    }
532484
private function getSmtpUsername($storeId = null)
    {
        return $this->scopeConfig->getValue(
            self::XML_PATH_DDG_TRANSACTIONAL_USERNAME,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
            $storeId
        );
    }
1129923
private function getShopOrderStepList($languageId)
    {
        $query = 'SELECT * FROM `shop_order_step` ORDER BY `position`';
        $statement = $this->databaseConnection->prepare($query);
        $statement->execute();
        $steps = array();
        while ($row = $statement->fetch()) {
            $step = new TdbShopOrderStep();
            $step->SetLanguage($languageId);
            $step->LoadFromRow($row);
            $steps[] = $step;
        }

        return $steps;
    }
171221
protected function loadStoreId() {
    $query = Drupal::entityQuery('commerce_store');
    $result = $query->execute();

    // There should only ever be one value returned so we naively use the first
    // item in the array. This should generally be safe as this should only run
    // within a Drupal site install context.
    $storeId = NULL;
    if (count($result) > 0) {
      $storeId = reset($result);
    }

    return $storeId;
  }
1132567
public function editStore($store_id = null)
    {
        $this->setStore($store_id);
        $this->seTitleEditStore();
        $this->setBreadcrumbEditStore();

        $this->setData('store', $this->data_store);
        $this->setData('themes', $this->getListThemeStore());
        $this->setData('is_default', $this->isDefaultStore());
        $this->setData('can_delete', $this->canDeleteStore());
        $this->setData('countries', $this->getCountriesStore());
        $this->setData('collections', $this->getListCollectionStore());
        $this->setData('languages', $this->language->getList(array('enabled' => true)));

        $this->submitEditStore();
        $this->setDataEditStore();

        $this->setJsEditStore();
        $this->outputEditStore();
    }
231737
public function getTableSpecification($storeName, $tid)
    {
        if (isset($this->tableSpecs[$storeName]) && isset($this->tableSpecs[$storeName][$tid]))
        {
            return $this->tableSpecs[$storeName][$tid];
        }
        else
        {
            return null;
        }
    }
1096582
public function &getStorage($storage_name): LanguageStorage
    {
        $return = false;

        if (isset($storage_name, $this->storage->{$storage_name})) {
            $return = $this->storage->{$storage_name};
        }

        return $return;
    }
574803
protected function updateStore($store_id)
    {
        if (!$this->isError() && !$this->store->update($store_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
1005252
public function find($id, $lang = null)
  {
    $results = $this->client->request([
      'ids' => $id,
      'languages' => $lang
    ]);

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

    return $results->first();
  }
48988
public function getProgramsByLocation($location_id) {
    $cid = __METHOD__ . $location_id;
    if ($cache = $this->cache->get($cid)) {
      return $cache->data;
    }

    $data = $this->client->getPrograms(['branch' => $location_id]);

    $this->cache->set($cid, $data);
    return $data;
  }