本文整理汇总了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;
}
示例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()];
}
示例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();
}
}
}
示例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();
}
}
}