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;
     });
 }
Example #2
0
 /**
  * Provide some Pimple resources on top of what's available in the Standalone
  * bootstrap.
  */
 public function init()
 {
     $this->pimple['debug'] = $this->pimple->share(function () {
         /* @var $config Config */
         $config = $this->pimple['config'];
         return $config->has('debug') && $config->get('debug');
     });
     $this->pimple['db'] = $this->pimple->share(function () {
         /* @var $pdo \PDO */
         $pdo = Zend_Db_Table_Abstract::getDefaultAdapter()->getConnection();
         $adapter = new Adapter();
         $driver = new PgsqlDriver($adapter, $pdo);
         return $adapter;
     });
     $this->pimple['config'] = $this->pimple->share(function () {
         return new Config();
     });
     $this->pimple['view'] = $this->pimple->share(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;
     });
 }
Example #3
0
 /**
  * Render a partial view.  By default, the same script path used by this
  * view is passed along.  This escaper from this view is also passed to
  * the partial.
  *
  * @param string $template
  * @param array $data
  * @param string $scriptPath
  * @return string
  */
 public function partial($template, array $data, $scriptPath = null)
 {
     $partial = new View($this->escaper);
     $partial->assignInstance('headscript', $this->headScript());
     $partial->assignInstance('headlink', $this->headLink());
     // Pass along any custom helper class assignments to the newly created partial
     foreach ($this->helperClasses as $name => $className) {
         $partial->registerHelper($name, $className);
     }
     foreach ($this->helpers as $name => $helper) {
         if ($helper instanceof PageDelegateInterface) {
             /* @var $partialHelper PageDelegateInterface */
             $partialHelper = $partial->helper($name);
             $partialHelper->setPage($helper->getPage());
         }
     }
     $partial->setScriptPath($scriptPath ?: $this->scriptPath)->assign($data);
     return $partial->render($template);
 }