Skip to content

Commit

Permalink
updating to allow for charset/content-type in route-based config on View
Browse files Browse the repository at this point in the history
  • Loading branch information
enygma committed Aug 8, 2012
1 parent d85d324 commit 857bbfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions Shield/Shield.php
Expand Up @@ -69,17 +69,22 @@ public function __construct()
{ {
// set the APPPATH constant // set the APPPATH constant
if (!defined('APPPATH')) { if (!defined('APPPATH')) {
define('APPPATH',__DIR__.'../app'); define('APPPATH', __DIR__.'../app');
} }


// force all error messages // some global config
spl_autoload_register(array($this, '_load')); spl_autoload_register(array($this, '_load'));
set_error_handler(array($this, '_errorHandler')); set_error_handler(array($this, '_errorHandler'));
set_exception_handler(array($this, '_exceptionHandler')); set_exception_handler(array($this, '_exceptionHandler'));


// include our exceptions // include our exceptions
include_once 'Exception.php'; include_once 'Exception.php';


$this->init();
}

private function init()
{
// make our DI container // make our DI container
$this->di = new Di(); $this->di = new Di();


Expand Down Expand Up @@ -133,7 +138,7 @@ public function __call($func, $args)


if (isset($args[2])) { if (isset($args[2])) {
// we've been given a route-specific config, set it up! // 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])) { if (isset($args[1])) {
Expand Down
7 changes: 5 additions & 2 deletions Shield/View.php
Expand Up @@ -112,7 +112,8 @@ public function setContentType($type)
*/ */
public function getContentType() public function getContentType()
{ {
return $this->contentType; $cfg = $this->di->get('Config')->get('view.content-type');
return ($cfg !== null) ? $cfg : $this->contentType;
} }


/** /**
Expand All @@ -132,7 +133,9 @@ public function setCharset($charset)
*/ */
public function getCharset() 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;
} }


/** /**
Expand Down

0 comments on commit 857bbfb

Please sign in to comment.