예제 #1
0
파일: Translator.php 프로젝트: octava/cms
 /**
  * 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
0
 /**
  * {@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
0
 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
0
 /**
  * {@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
0
 /**
  * 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);
 }