Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,53 @@
<?php
/**
* @file
* Contains \Drupal\language\Config\LanguageConfigCollectionNameTrait.
*/
namespace Drupal\language\Config;
use Drupal\Component\Utility\SafeMarkup;
/**
* Provides a common trait for working with language override collection names.
*/
trait LanguageConfigCollectionNameTrait {
/**
* Creates a configuration collection name based on a language code.
*
* @param string $langcode
* The language code.
*
* @return string
* The configuration collection name for a language code.
*/
protected function createConfigCollectionName($langcode) {
return 'language.' . $langcode;
}
/**
* Converts a configuration collection name to a language code.
*
* @param string $collection
* The configuration collection name.
*
* @return string
* The language code of the collection.
*
* @throws \InvalidArgumentException
* Exception thrown if the provided collection name is not in the format
* "language.LANGCODE".
*
* @see self::createConfigCollectionName()
*/
protected function getLangcodeFromCollectionName($collection) {
preg_match('/^language\.(.*)$/', $collection, $matches);
if (!isset($matches[1])) {
throw new \InvalidArgumentException(SafeMarkup::format('!collection is not a valid language override collection', array('!collection' => $collection)));
}
return $matches[1];
}
}