Permalink
Browse files

updating to allow for charset/content-type in route-based config on View

  • Loading branch information...
1 parent d85d324 commit 857bbfb6204abaec07e4ab0b2c6c7ff7d1cb5774 @enygma committed Aug 8, 2012
Showing with 13 additions and 5 deletions.
  1. +8 −3 Shield/Shield.php
  2. +5 −2 Shield/View.php
View
@@ -69,17 +69,22 @@ public function __construct()
{
// set the APPPATH constant
if (!defined('APPPATH')) {
- define('APPPATH',__DIR__.'../app');
+ define('APPPATH', __DIR__.'../app');
}
- // force all error messages
+ // some global config
spl_autoload_register(array($this, '_load'));
set_error_handler(array($this, '_errorHandler'));
set_exception_handler(array($this, '_exceptionHandler'));
// include our exceptions
include_once 'Exception.php';
+ $this->init();
+ }
+
+ private function init()
+ {
// make our DI container
$this->di = new Di();
@@ -133,7 +138,7 @@ public function __call($func, $args)
if (isset($args[2])) {
// we've been given a route-specific config, set it up!
- $this->di->get('Config')->setConfig($args[2],'route::'.$path);
+ $this->di->get('Config')->setConfig($args[2], 'route::'.$path);
}
if (isset($args[1])) {
View
@@ -112,7 +112,8 @@ public function setContentType($type)
*/
public function getContentType()
{
- return $this->contentType;
+ $cfg = $this->di->get('Config')->get('view.content-type');
+ return ($cfg !== null) ? $cfg : $this->contentType;
}
/**
@@ -132,7 +133,9 @@ public function setCharset($charset)
*/
public function getCharset()
{
- return $this->charset;
+ // see if its in the config first
+ $cfg = $this->di->get('Config')->get('view.charset');
+ return ($cfg !== null) ? $cfg : $this->charset;
}
/**

0 comments on commit 857bbfb

Please sign in to comment.