Ejemplo n.º 1
0
 /**
  * Initializes this class.
  *
  * Available options:
  *
  *  * culture:             The culture
  *  * source:              The i18n source (XLIFF by default)
  *  * debug:               Whether to enable debug or not (false by default)
  *  * database:            The database name (default by default)
  *  * untranslated_prefix: The prefix to use when a message is not translated
  *  * untranslated_suffix: The suffix to use when a message is not translated
  *
  * @param sfApplicationConfiguration $configuration   A sfApplicationConfiguration instance
  * @param sfCache                    $cache           A sfCache instance
  * @param array                      $options         An array of options
  */
 public function initialize(sfApplicationConfiguration $configuration, sfCache $cache = null, $options = array())
 {
     $this->configuration = $configuration;
     $this->dispatcher = $configuration->getEventDispatcher();
     $this->cache = $cache;
     if (isset($options['culture'])) {
         $this->setCulture($options['culture']);
         unset($options['culture']);
     }
     $this->options = array_merge(array('source' => 'XLIFF', 'debug' => false, 'database' => 'default', 'untranslated_prefix' => '[T]', 'untranslated_suffix' => '[/T]'), $options);
     $this->dispatcher->connect('user.change_culture', array($this, 'listenToChangeCultureEvent'));
     if ($this->isMessageSourceFileBased($this->options['source'])) {
         $this->dispatcher->connect('controller.change_action', array($this, 'listenToChangeActionEvent'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Initializes the current sfContext instance.
  *
  * @param sfApplicationConfiguration $configuration  An sfApplicationConfiguration instance
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     $this->configuration = $configuration;
     $this->dispatcher = $configuration->getEventDispatcher();
     try {
         $this->loadFactories();
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
     $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
     // register our shutdown function
     register_shutdown_function(array($this, 'shutdown'));
 }