當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LanguageManagerInterface::getLanguageConfigOverride方法代碼示例

本文整理匯總了PHP中Drupal\Core\Language\LanguageManagerInterface::getLanguageConfigOverride方法的典型用法代碼示例。如果您正苦於以下問題:PHP LanguageManagerInterface::getLanguageConfigOverride方法的具體用法?PHP LanguageManagerInterface::getLanguageConfigOverride怎麽用?PHP LanguageManagerInterface::getLanguageConfigOverride使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Language\LanguageManagerInterface的用法示例。


在下文中一共展示了LanguageManagerInterface::getLanguageConfigOverride方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: routes

 /**
  * Returns an array of route objects.
  *
  * @return \Symfony\Component\Routing\Route[]
  *   An array of route objects.
  */
 public function routes()
 {
     $routes = array();
     $is_multilingual = $this->languageManager->isMultilingual();
     /* @var $search_api_page \Drupal\search_api_page\SearchApiPageInterface */
     foreach ($this->entityManager->getStorage('search_api_page')->loadMultiple() as $search_api_page) {
         // Default path.
         $default_path = $search_api_page->getPath();
         // Loop over all languages so we can get the translated path (if any).
         foreach ($this->languageManager->getLanguages() as $language) {
             // Check if we are multilingual or not.
             if ($is_multilingual) {
                 $path = $this->languageManager->getLanguageConfigOverride($language->getId(), 'search_api_page.search_api_page.' . $search_api_page->id())->get('path');
             }
             if (empty($path)) {
                 $path = $default_path;
             }
             $args = ['_controller' => 'Drupal\\search_api_page\\Controller\\SearchApiPageController::page', 'search_api_page_name' => $search_api_page->id()];
             // Use clean urls or not.
             if ($search_api_page->getCleanUrl()) {
                 $path .= '/{keys}';
                 $args['keys'] = '';
             }
             $routes['search_api_page.' . $language->getId() . '.' . $search_api_page->id()] = new Route($path, $args, array('_permission' => 'view search api pages'));
         }
     }
     return $routes;
 }
開發者ID:nB-MDSO,項目名稱:mdso-d8blog,代碼行數:34,代碼來源:SearchApiPageRoutes.php

示例2: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     if ($row->hasDestinationProperty('langcode')) {
         $this->config = $this->language_manager->getLanguageConfigOverride($row->getDestinationProperty('langcode'), $this->config->getName());
     }
     foreach ($row->getRawDestination() as $key => $value) {
         if (isset($value) || !empty($this->configuration['store null'])) {
             $this->config->set(str_replace(Row::PROPERTY_SEPARATOR, '.', $key), $value);
         }
     }
     $this->config->save();
     return [$this->config->getName()];
 }
開發者ID:systemick3,項目名稱:systemick.co.uk,代碼行數:16,代碼來源:Config.php

示例3: importTranslations

 /**
  * {@inheritdoc}
  */
 public function importTranslations(array $langcodes)
 {
     $available_translations = $this->getAvailableTranslations();
     $available_translations = array_intersect_key($available_translations, array_flip($langcodes));
     foreach ($available_translations as $langcode => $country_codes) {
         $address_formats = $this->storage->loadMultiple($country_codes);
         foreach ($address_formats as $country_code => $address_format) {
             $external_translation = $this->externalRepository->get($country_code, $langcode);
             $config_name = $address_format->getConfigDependencyName();
             $config_translation = $this->languageManager->getLanguageConfigOverride($langcode, $config_name);
             $config_translation->set('format', $external_translation->getFormat());
             $config_translation->save();
         }
     }
 }
開發者ID:r-daneelolivaw,項目名稱:chalk,代碼行數:18,代碼來源:AddressFormatImporter.php

示例4: importEntityTranslations

  /**
   * Imports translations for the given currency entity.
   *
   * @param \Drupal\commerce_price\Entity\CurrencyInterface $currency
   *   The currency entity.
   * @param array $langcodes
   *   The langcodes.
   */
  protected function importEntityTranslations(CurrencyInterface $currency, array $langcodes) {
    $currencyCode = $currency->getCurrencyCode();
    $configName = $currency->getConfigDependencyName();
    foreach ($langcodes as $langcode) {
      try {
        $translatedCurrency = $this->externalRepository->get($currencyCode, $langcode);
      }
      catch (UnknownLocaleException $e) {
        // No translation found.
        continue;
      }

      $configTranslation = $this->languageManager->getLanguageConfigOverride($langcode, $configName);
      if ($configTranslation->isNew()) {
        $configTranslation->set('name', $translatedCurrency->getName());
        $configTranslation->set('symbol', $translatedCurrency->getSymbol());
        $configTranslation->save();
      }
    }
  }
開發者ID:housineali,項目名稱:drpl8_dv,代碼行數:28,代碼來源:CurrencyImporter.php


注:本文中的Drupal\Core\Language\LanguageManagerInterface::getLanguageConfigOverride方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。