Phalcon Framework 4.1.2

Phalcon\Translate\Exception: Translation data must be an array

phalcon/Translate/Adapter/NativeArray.zep (57)
#0Phalcon\Translate\Adapter\NativeArray->__construct
#1Phalcon\Translate\TranslateFactory->newInstance
/var/www/htdocs/app/components/Language.php (41)
<?PHP
namespace LOID\Component;
 
class Language extends \Phalcon\Di\Injectable{
  // Keyed by language name, values are file names
  private static $languages;
 
  private static $language;
  private static $language_file = NULL;
 
  public static function getPreferredLanguage(){
    // Get the language from the session
    if(\Phalcon\DI::getDefault()->getSession()->get('language')){
      $language = \Phalcon\DI::getDefault()->getSession()->get('language');
    }
    else{
      // Get the language from the browser
      $language = self::removePreferredDialect(\Phalcon\DI::getDefault()->getRequest()->getBestLanguage());
    }
 
    if(self::langFileExists($language))
      self::$language_file = self::$languages[$language];
    else
      self::$language_file = self::$languages[\Phalcon\DI::getDefault()->getConfig()->language_default];
 
    self::$language = $language;
    \Phalcon\DI::getDefault()->getSession()->set('language',$language);
  }
 
  public static function getTranslator(){
    if(self::$language_file == NULL)
      self::getPreferredLanguage();
 
    $Interpolator = new \Phalcon\Translate\InterpolatorFactory;
    $Factory = new \Phalcon\Translate\TranslateFactory($Interpolator);
    $messages = [];
    $messages = include \Phalcon\DI::getDefault()->getConfig()->dirs->languages.'/'.self::$language_file;
    $options = [
      'content'=>$messages
    ];
    $Translator = $Factory->newInstance('array',$options);
 
    return $Translator;
 
 
    // $messages = new \Phalcon\Translate\Adapter\NativeArray([
    //         'content'=>include(\Phalcon\DI::getDefault()->getConfig()->dirs->languages.'/'.self::$language_file)
    //       ]);  
 
    // return $messages;
  }
 
  public static function getLanguage(){
    return self::$language;
  }
 
  public static function setLanguage($language){
    \Phalcon\DI::getDefault()->getSession()->set('language',$language);
    self::getPreferredLanguage();
  }
  /* Retrieves all available language files
   * Saves self::$languages as an array keyed by language name, valued by filenames
   * Anything before the first period is used as the language name:
   * So: en.php     = en   // OK
   *     en-US.php   = en-US  // OK
   *     en.US.php   = en   // Probably not OK
   */
  private static function getAvailableLanguages(){
    $langs = [];
 
    chdir(\Phalcon\DI::getDefault()->getConfig()->dirs->languages);
    $files = glob('*');
 
    foreach($files as $filename){
      $lang = substr($filename,0,strpos($filename,'.'));
      $langs[$lang] = $filename;
    }
 
    self::$languages = $langs;
  }
 
  /* Simply checks if a corresponding language file exists */
  private static function langFileExists($language){
    self::getAvailableLanguages();
    return isset(self::$languages[$language]);
  }
 
 
  /* Strips any dialect (ie: en-US - removes "-US") from the preferred language */
  private static function removePreferredDialect($language_name){
    list($language,$dialect) = explode('-',$language_name);
    return $language;
  }
 
  
}
#2LOID\Component\Language::getTranslator
/var/www/htdocs/app/controllers/ControllerBase.php (44)
<?php
/*
 * This controller isn't intended to be called when the /base/ URL is visited,
 * Rather it's a base class other controllers extend
 */
 
use LOID\Component\Feedback,
  LOID\Model\User;
 
 
class ControllerBase extends \Phalcon\Mvc\Controller{
  protected $loadFeedback = TRUE;
 
  public function beforeExecuteRoute(){
 
    // Feedback is singleton, so view assignment can be done here
    // and errors added later will still be accessible in the view
    if($this->loadFeedback){
      Feedback::get()->getFlashedMessages();
      $this->view->Feedback = Feedback::get();
    }
 
    if($this->request->isPost()){
      if(!$this->csrf->checkToken()){
        exit('CSRF token not set');
      }
    }
 
    $this->view->csrf_key   = $this->csrf->getTokenKey();
    $this->view->csrf_value = $this->csrf->getToken();
 
    if($this->session->has('authenticated'))
      $this->LoggedInUser = $this->view->LoggedInUser = User::findFirstByKey($this->session->get('username'));
  
    // Add the translator
    $this->setLanguage();
  }
 
  public function setLanguage($language = NULL){
    if($language != NULL){
      \LOID\Component\Language::setLanguage($language);
    }
 
    $Translator           =  \LOID\Component\Language::getTranslator();
    $this->view->t        = $Translator;
    $this->Translator     = $Translator;
    $this->view->language = \LOID\Component\Language::getLanguage();
 
  }
}
#3ControllerBase->setLanguage
/var/www/htdocs/app/controllers/ControllerBase.php (36)
<?php
/*
 * This controller isn't intended to be called when the /base/ URL is visited,
 * Rather it's a base class other controllers extend
 */
 
use LOID\Component\Feedback,
  LOID\Model\User;
 
 
class ControllerBase extends \Phalcon\Mvc\Controller{
  protected $loadFeedback = TRUE;
 
  public function beforeExecuteRoute(){
 
    // Feedback is singleton, so view assignment can be done here
    // and errors added later will still be accessible in the view
    if($this->loadFeedback){
      Feedback::get()->getFlashedMessages();
      $this->view->Feedback = Feedback::get();
    }
 
    if($this->request->isPost()){
      if(!$this->csrf->checkToken()){
        exit('CSRF token not set');
      }
    }
 
    $this->view->csrf_key   = $this->csrf->getTokenKey();
    $this->view->csrf_value = $this->csrf->getToken();
 
    if($this->session->has('authenticated'))
      $this->LoggedInUser = $this->view->LoggedInUser = User::findFirstByKey($this->session->get('username'));
  
    // Add the translator
    $this->setLanguage();
  }
 
  public function setLanguage($language = NULL){
    if($language != NULL){
      \LOID\Component\Language::setLanguage($language);
    }
 
    $Translator           =  \LOID\Component\Language::getTranslator();
    $this->view->t        = $Translator;
    $this->Translator     = $Translator;
    $this->view->language = \LOID\Component\Language::getLanguage();
 
  }
}
#4ControllerBase->beforeExecuteRoute
#5Phalcon\Dispatcher\AbstractDispatcher->dispatch
#6Phalcon\Mvc\Application->handle
/var/www/htdocs/public/index.php (18)
<?php
$Debug = new \Phalcon\Debug();
$Debug->setUri('https://loid.augustana.ualberta.ca/public/assets/debug/');
$Debug->listen();
 
#try{
  
  require '../app/config/bootstrap.php';
 
  #
  # Handle the requested URL
  #
  $App = new \Phalcon\Mvc\Application($DI);
 
  #
  # Echo the output
  #
  echo $App->handle($Config->dirs->application_request_uri)->getContent();
 
  
/*
}
catch(\Phalcon\Exception $e){
  echo 'Phalcon Exception: ',$e->getMessage();
}
*/
KeyValue
_url/login/
returnapply/75
KeyValue
REDIRECT_REDIRECT_HTTPSon
REDIRECT_REDIRECT_SSL_TLS_SNIloid.augustana.ualberta.ca
REDIRECT_REDIRECT_STATUS200
REDIRECT_HTTPSon
REDIRECT_SSL_TLS_SNIloid.augustana.ualberta.ca
REDIRECT_STATUS200
HTTPSon
SSL_TLS_SNIloid.augustana.ualberta.ca
SSL_SERVER_S_DN_CCA
SSL_SERVER_S_DN_STAlberta
SSL_SERVER_S_DN_LEdmonton
SSL_SERVER_S_DN_OUniversity of Alberta
SSL_SERVER_S_DN_CN*.augustana.ualberta.ca
SSL_SERVER_I_DN_CBE
SSL_SERVER_I_DN_OGlobalSign nv-sa
SSL_SERVER_I_DN_CNGlobalSign RSA OV SSL CA 2018
SSL_SERVER_SAN_DNS_0*.augustana.ualberta.ca
SSL_SERVER_SAN_DNS_1augustana.ualberta.ca
SSL_VERSION_INTERFACEmod_ssl/2.4.62
SSL_VERSION_LIBRARYOpenSSL/1.1.1w
SSL_PROTOCOLTLSv1.3
SSL_SECURE_RENEGtrue
SSL_COMPRESS_METHODNULL
SSL_CIPHERTLS_AES_256_GCM_SHA384
SSL_CIPHER_EXPORTfalse
SSL_CIPHER_USEKEYSIZE256
SSL_CIPHER_ALGKEYSIZE256
SSL_CLIENT_VERIFYNONE
SSL_SERVER_M_VERSION3
SSL_SERVER_M_SERIAL0335E47EE9F963E531BC9BF3
SSL_SERVER_V_STARTFeb 21 14:56:05 2024 GMT
SSL_SERVER_V_ENDMar 24 14:56:04 2025 GMT
SSL_SERVER_S_DNCN=*.augustana.ualberta.ca,O=University of Alberta,L=Edmonton,ST=Alberta,C=CA
SSL_SERVER_I_DNCN=GlobalSign RSA OV SSL CA 2018,O=GlobalSign nv-sa,C=BE
SSL_SERVER_A_KEYrsaEncryption
SSL_SERVER_A_SIGsha256WithRSAEncryption
SSL_SESSION_ID5d12bb8d33260a524b7759bd3489230fa693329a2cfe7e37229329ea89d6e405
SSL_SESSION_RESUMEDInitial
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT_ENCODINGgzip, br, zstd, deflate
HTTP_REFERERhttps://loid.augustana.ualberta.ca/apply/75
HTTP_COOKIEPHPSESSID=audcadsb488ddsahmpavfddpth
HTTP_HOSTloid.augustana.ualberta.ca
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SERVER_SIGNATURE<address>Apache/2.4.62 (Debian) Server at loid.augustana.ualberta.ca Port 443</address>\n
SERVER_SOFTWAREApache/2.4.62 (Debian)
SERVER_NAMEloid.augustana.ualberta.ca
SERVER_ADDR142.244.26.151
SERVER_PORT443
REMOTE_ADDR3.145.56.150
DOCUMENT_ROOT/var/www/htdocs
REQUEST_SCHEMEhttps
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT/var/www/htdocs
SERVER_ADMINwebmaster@localhost
SCRIPT_FILENAME/var/www/htdocs/public/index.php
REMOTE_PORT23209
REDIRECT_URL/public/login/
REDIRECT_QUERY_STRING_url=/login/&return=apply/75
GATEWAY_INTERFACECGI/1.1
SERVER_PROTOCOLHTTP/1.1
REQUEST_METHODGET
QUERY_STRING_url=/login/&return=apply/75
REQUEST_URI/login/?return=apply/75
SCRIPT_NAME/public/index.php
PHP_SELF/public/index.php
REQUEST_TIME_FLOAT1732996082.516
REQUEST_TIME1732996082
#Path
0/var/www/htdocs/public/index.php
1/var/www/htdocs/app/config/bootstrap.php
2/var/www/htdocs/app/libraries/dump.php
3/var/www/htdocs/app/libraries/vendor/autoload.php
4/var/www/htdocs/app/libraries/vendor/composer/autoload_real.php
5/var/www/htdocs/app/libraries/vendor/composer/platform_check.php
6/var/www/htdocs/app/libraries/vendor/composer/ClassLoader.php
7/var/www/htdocs/app/libraries/vendor/composer/autoload_static.php
8/var/www/htdocs/app/libraries/vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php
9/var/www/htdocs/app/config/config.php
10/var/www/htdocs/app/components/Auth.php
11/var/www/htdocs/app/controllers/LoginController.php
12/var/www/htdocs/app/controllers/ControllerBase.php
13/var/www/htdocs/app/components/ACL.php
14/var/www/htdocs/app/components/Feedback.php
15/var/www/htdocs/app/components/CSRF.php
16/var/www/htdocs/app/components/Language.php
17/var/www/htdocs/app/lang/_README
Memory
Usage2097152