本文整理匯總了PHP中Symfony\Bundle\FrameworkBundle\Translation\Translator::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translator::__construct方法的具體用法?PHP Translator::__construct怎麽用?PHP Translator::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Bundle\FrameworkBundle\Translation\Translator
的用法示例。
在下文中一共展示了Translator::__construct方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Constructor.
*
* Available options:
*
* * cache_dir: The cache directory (or null to disable caching)
* * debug: Whether to enable debugging or not (false by default)
* * resource_files: List of translation resources available grouped by locale.
*
* @param ContainerInterface $container A ContainerInterface instance
* @param MessageSelector $selector The message selector for pluralization
* @param array $loaderIds An array of loader Ids
* @param array $options An array of options
*
* @throws \InvalidArgumentException
*/
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = [], array $options = [])
{
$domains = $resources = [];
foreach ($options['resource_files'] as $locale => $files) {
foreach ($files as $file) {
if (preg_match('!([^.]+)\\.([^.]+)\\.[^\\.]+$!', basename($file), $a)) {
$resources[] = $file;
$domains[] = $a[1];
}
}
}
try {
$locales = $container->get('octava_mui.locale_manager')->getAllAliases();
foreach ($domains as $domain) {
foreach ($locales as $locale) {
if (empty($options['resource_files'][$locale])) {
$options['resource_files'][$locale] = [];
}
$options['resource_files'][$locale][] = $domain . '.' . $locale . '.zdb';
}
}
} catch (DBALException $e) {
//for unit test, if cache empty and db scheme not created
}
$this->resources = $options['resource_files'];
parent::__construct($container, $selector, $loaderIds, $options);
}
示例2: __construct
/**
* {@inheritdoc}
*/
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = [], array $options = [])
{
$this->selector = $selector;
$this->themeRepository = $container->get('sylius.theme.repository');
$this->themeContext = $container->get('sylius.theme.context');
$this->resourcesToThemes = new ArrayCollection();
parent::__construct($container, $selector, $loaderIds, $options);
}
示例3: __construct
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array())
{
parent::__construct($container, $selector, $loaderIds, $options);
$this->memcached = $container->get('php.memcache');
}
示例4: __construct
/**
* {@inheritdoc}
*
* @api
*/
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = [], array $options = [])
{
parent::__construct($container, $selector, $loaderIds, $options);
$this->selector = $selector;
$this->container = $container;
}
示例5: __construct
/**
* Constructor.
*
* Available options:
*
* * cache_dir: The cache directory (or null to disable caching)
* * debug: Whether to enable debugging or not (false by default)
* * resource_files: List of translation resources available grouped by locale.
*
* @param ContainerInterface $container A ContainerInterface instance
* @param MessageSelector $selector The message selector for pluralization
* @param array $loaderIds An array of loader Ids
* @param array $options An array of options
*
* @throws \InvalidArgumentException
*/
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array())
{
$options['resource_files'] = $container->get('graviton.18n.cacheutils')->getResources($options['resource_files']);
parent::__construct($container, $selector, $loaderIds, $options);
}