1: <?php
2:
3: namespace PHPixie\Bundles;
4:
5: class Builder
6: {
7: protected $bundleRegistry;
8: protected $configData;
9:
10: protected $instances = array();
11:
12: public function __construct($bundleRegistry, $configData)
13: {
14: $this->bundleRegistry = $bundleRegistry;
15: $this->configData = $configData;
16: }
17:
18: public function config($name)
19: {
20: return $this->configData->slice($name);
21: }
22:
23: public function registry()
24: {
25: return $this->bundleRegistry;
26: }
27:
28: public function httpProcessors()
29: {
30: return $this->instance('httpProcessors');
31: }
32:
33: public function templateLocators()
34: {
35: return $this->instance('templateLocators');
36: }
37:
38: public function routeResolvers()
39: {
40: return $this->instance('routeResolvers');
41: }
42:
43: public function orm()
44: {
45: return $this->instance('orm');
46: }
47:
48: public function auth()
49: {
50: return $this->instance('auth');
51: }
52:
53: protected function instance($name)
54: {
55: if(!array_key_exists($name, $this->instances)) {
56: $method = 'build'.ucfirst($name);
57: $this->instances[$name] = $this->$method();
58: }
59:
60: return $this->instances[$name];
61: }
62:
63: protected function buildHttpProcessors()
64: {
65: return new Processors\HTTP($this->bundleRegistry);
66: }
67:
68: protected function buildTemplateLocators()
69: {
70: return new FilesystemLocators\Template($this->bundleRegistry);
71: }
72:
73: protected function buildRouteResolvers()
74: {
75: return new RouteResolvers($this->bundleRegistry);
76: }
77:
78: protected function buildOrm()
79: {
80: return new ORM($this->bundleRegistry);
81: }
82:
83: protected function buildAuth()
84: {
85: return new Auth($this->bundleRegistry);
86: }
87: }