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