get() public method

Get the config model
public get ( ) : Config
return Xinax\LaravelGettext\Config\Models\Config
 /**
  * @expectedException \Xinax\LaravelGettext\Exceptions\UndefinedDomainException
  */
 public function testTranslations()
 {
     /** @var \Xinax\LaravelGettext\Session\SessionHandler|\Mockery\MockInterface $session */
     $session = m::mock('Xinax\\LaravelGettext\\Session\\SessionHandler');
     $session->shouldReceive('get')->andReturn('es_AR');
     $session->shouldReceive('set');
     /** @var \Xinax\LaravelGettext\Adapters\LaravelAdapter|\Mockery\MockInterface $adapter */
     $adapter = m::mock('Xinax\\LaravelGettext\\Adapters\\LaravelAdapter');
     $adapter->shouldReceive('setLocale');
     $adapter->shouldReceive('getApplicationPath')->andReturn(dirname(__FILE__));
     $config = $this->configManager->get();
     // Static traslation files
     $config->setTranslationsPath("translations");
     $gettext = new Gettext($config, $session, $adapter, $this->fileSystem);
     $laravelGettext = new LaravelGettext($gettext);
     $laravelGettext->setLocale("es_AR");
     $this->assertSame("Cadena general con echo de php", _("general string with php echo"));
     $laravelGettext->setDomain("backend");
     $this->assertSame("backend", $laravelGettext->getDomain());
     $this->assertSame("Cadena en el backend con echo de php", _("Backend string with php echo"));
     $laravelGettext->setDomain("frontend");
     $this->assertSame("frontend", $laravelGettext->getDomain());
     $this->assertSame("Cadena de controlador", _("Controller string"));
     $this->assertSame("Cadena de frontend con echo de php", _("Frontend string with php echo"));
     $laravelGettext->setLocale("en_US");
     $this->assertSame("Frontend string with php echo", _("Frontend string with php echo"));
     // Expected exception
     $laravelGettext->setDomain("wrong-domain");
 }
Beispiel #2
0
 /**
  * Sets the configuration and session manager
  */
 public function __construct(ConfigManager $configMan, SessionHandler $sessionHandler, AdapterInterface $adapter)
 {
     // Sets the package configuration and session handler
     $this->configuration = $configMan->get();
     $this->session = $sessionHandler;
     $this->adapter = $adapter;
     // Encoding is set on configuration
     $this->encoding = $this->configuration->getEncoding();
     // Sets defaults for boot
     $locale = $this->session->get($this->configuration->getLocale());
     $this->setLocale($locale);
 }
Beispiel #3
0
 /**
  * Create a new command instance.
  * @return void
  */
 public function __construct()
 {
     $configManager = new ConfigManager();
     $this->configuration = $configManager->get();
     parent::__construct();
 }