コード例 #1
0
ファイル: Module.php プロジェクト: Mendim/ep3-bs
 public function onBootstrap(EventInterface $e)
 {
     $serviceManager = $e->getApplication()->getServiceManager();
     /* Check database */
     $dbAdapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
     $dbConnection = $dbAdapter->getDriver()->getConnection();
     try {
         $dbConnection->connect();
     } catch (\RuntimeException $e) {
         include 'Charon.php';
         Charon::carry('application', 'configuration', 1);
     }
     /* Set global validator translator */
     $translator = $serviceManager->get('Translator');
     AbstractValidator::setDefaultTranslator($translator);
 }
コード例 #2
0
ファイル: OptionManager.php プロジェクト: Mendim/ep3-bs
 /**
  * Creates a new option manager object.
  *
  * Preloads all available options from the database.
  *
  * @param OptionTable $optionTable
  * @param string $locale
  */
 public function __construct(OptionTable $optionTable, $locale)
 {
     $this->optionTable = $optionTable;
     $this->locale = $locale;
     /* Preload all available options that match the passed locale (or fall back to null ones). */
     $select = $optionTable->getSql()->select();
     $select->where(array(new IsNull('locale'), new Operator('locale', '=', $locale)), Predicate::COMBINED_BY_OR);
     $select->order('locale DESC');
     try {
         $options = $this->optionTable->selectWith($select);
     } catch (RuntimeException $e) {
         include 'module/Base/Charon.php';
         Charon::carry('application', 'database', 1);
     }
     foreach ($options as $option) {
         if (!isset($this->options[$option->key])) {
             $this->options[$option->key] = $option->value;
         }
     }
 }