public function addPimpleResources()
 {
     $this->silex['paths'] = $this->silex->share(function () {
         return new Paths();
     });
     $this->silex['application-env'] = getenv('APPLICATION_ENV');
     $this->silex['debug'] = 'development' === $this->silex['application-env'] ? true : false;
     $this->silex->register(new MonologServiceProvider(), ['monolog.logfile' => $this->silex['paths']->getAppRoot() . '/logs/' . $this->silex['application-env'] . '.log', 'monolog.level' => Logger::WARNING]);
     $this->silex['view'] = function () {
         $view = new View();
         $view->registerHelper('inputtext', '\\Dewdrop\\View\\Helper\\BootstrapInputText')->registerHelper('select', '\\Dewdrop\\View\\Helper\\BootstrapSelect')->registerHelper('textarea', '\\Dewdrop\\View\\Helper\\BootstrapTextarea');
         return $view;
     };
     $this->silex['admin'] = $this->silex->share(function () {
         $admin = new SilexAdmin($this->silex);
         return $admin;
     });
     $this->silex['config'] = $this->silex->share(function () {
         $config = new Config();
         if (!$config->has($this->silex['application-env'])) {
             return $config->get('development');
         }
         return $config->get($this->silex['application-env']);
     });
     $this->silex['db'] = $this->silex->share(function () {
         $config = $this->silex['config'];
         $pdo = new PDO('pgsql:dbname=' . $config['db']['name'] . ';host=' . $config['db']['host'], $config['db']['username'], $config['db']['password']);
         $adapter = new DbAdapter();
         new Pgsql($adapter, $pdo);
         return $adapter;
     });
 }
Exemple #2
0
 /**
  * Load the application's bootstrap and retrieve the Pimple DI object
  * from it.  Your Pimple object must provide some basic resources to
  * work with Dewdrop.
  *
  * @return Pimple
  */
 public static function findPimple()
 {
     $config = new Config();
     if (!$config->has('bootstrap')) {
         throw new Exception('Please define a bootstrap class in your dewdrop-config.php.');
     } else {
         $bootstrapClass = $config->get('bootstrap');
         $bootstrap = new $bootstrapClass();
         if (!$bootstrap instanceof PimpleProviderInterface) {
             throw new Exception('Your bootstrap class must implement the PimpleProviderInterface.');
         }
         $pimple = $bootstrap->getPimple();
         self::validatePimple($pimple);
         self::augmentPimpleWithDefaultResources($pimple);
         return $pimple;
     }
 }