/** * Set application locale based on context. * We doing this here because it's simpler than create a middleware just for this * and the application locale is strongly bind to the current context */ private function setApplicationLocale() { //If we have a user in context, the user locale prevail the account local if ($this->context->hasUser()) { //Set the local from user $this->setLocaleFromUser($this->context->user()); return; } //If we have account, set the locale from account if ($this->context->hasAccount()) { $this->setLocaleFromAccount($this->context->account()); } return; }
public function testHasNoUser() { $context = new Context(); $this->assertFalse($context->hasUser()); $this->assertNull($context->user()); }