Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more on the conversion away from the DI into standard injection

  • Loading branch information...
commit b7026efc94f5be3bc7122126a0417b539bf45bf6 1 parent 0e3c192
Chris Cornutt authored
Showing with 33 additions and 6 deletions.
  1. +3 −1 Shield/Shield.php
  2. +7 −0 Shield/Template.php
  3. +23 −5 Shield/View.php
View
4 Shield/Shield.php
@@ -95,8 +95,10 @@ private function init()
$bs = new Bootstrap($this->di);
+ $template = new Template($config);
+
// set up the view and logger objects
- $this->view = new View($this->di);
+ $this->view = new View($config,$template);
$this->log = new Log($config);
$this->di->register(array($this->view, $this->log));
View
7 Shield/Template.php
@@ -4,6 +4,13 @@
class Template extends Base
{
+ private $config = null;
+
+ public function __construct(\Shield\Config $config)
+ {
+ $this->config = $config;
+ }
+
/**
* Template properties (values)
* @var array
View
28 Shield/View.php
@@ -16,8 +16,16 @@ class View extends Base
*/
private $_viewDir = null;
+ /**
+ * Default Content-Type
+ * @var string
+ */
private $contentType = 'text/html';
+ /**
+ * Default Character Set
+ * @var string
+ */
private $charset = 'UTF-8';
/**
@@ -27,16 +35,24 @@ class View extends Base
public $template = null;
/**
+ * A \Shield\Config object
+ * @var object
+ */
+ private $config = null;
+
+ /**
* Init the object and create a Template instance
*
* @param object $di DI container
*/
- public function __construct($di)
+ public function __construct(\Shield\Config $config, \Shield\Template $template)
{
- $this->template = new Template($di);
+ //$this->template = new Template($di);
+ $this->config = $config;
+ $this->template = $template;
$this->setViewDir();
- parent::__construct($di);
+ //parent::__construct($di);
}
/**
@@ -112,7 +128,8 @@ public function setContentType($type)
*/
public function getContentType()
{
- $cfg = $this->di->get('Config', true)->get('view.content-type');
+ //$cfg = $this->di->get('Config', true)->get('view.content-type');
+ $cfg = $this->config->get('view.content-type');
return ($cfg !== null) ? $cfg : $this->contentType;
}
@@ -134,7 +151,8 @@ public function setCharset($charset)
public function getCharset()
{
// see if its in the config first
- $cfg = $this->di->get('Config', true)->get('view.charset');
+ //$cfg = $this->di->get('Config', true)->get('view.charset');
+ $cfg = $this->config->get('view.charset');
return ($cfg !== null) ? $cfg : $this->charset;
}

1 comment on commit b7026ef

@g-alonso

Hello! Why did you do this? is not preferable to use DIC?

Please sign in to comment.
Something went wrong with that request. Please try again.