Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Controller
- {
- protected $db;
- private $article;
- private $nav;
- public function __construct($db)
- {
- $this->db = $db;
- $this->article = new Article($this->db);
- $this->nav = new Nav($this->db);
- }
- public function render($template)
- {
- var_dump($this->article->getRow());
- var_dump($this->nav->getRows());
- }
- }
- class Controller
- {
- private $container;
- public function __construct()
- {
- }
- public function render($container,$template)
- {
- $this->container = $container;
- var_dump($this->container->getArticle($url = 'home'));
- var_dump($this->container->getNav());
- }
- }
- class Container
- {
- protected $db;
- private $article;
- private $nav;
- public function __construct($db)
- {
- $this->db = $db;
- }
- public function setArticle()
- {
- if (is_null($this->article))
- {
- $this->article = new Article($this->db);
- }
- return $this->article;
- }
- public function setNav()
- {
- if (is_null($this->nav))
- {
- $this->nav = new Nav($this->db);
- }
- return $this->nav;
- }
- public function getArticle($url)
- {
- return $this->setArticle()->getRow($url);
- }
- public function getNav()
- {
- return $this->setNav()->getRows();
- }
- }
- class Article
- {
- public function __construct($db)
- {
- }
- public function getRow($url)
- {
- return "row 1";
- }
- }
- class nav
- {
- public function __construct($db)
- {
- }
- public function getRows()
- {
- return "rows nav";
- }
- }
- $db = 'pdo connection';
- $template = 'template.phtml';
- $container = new Container($db);
- $controller = new Controller();
- $controller->render($container,$template);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement