1 <?php
2 /* --------------------------------------------------------------
3 HttpServiceFactory.inc.php 2015-03-12 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('HttpServiceFactoryInterface');
13
14 /**
15 * Class HttpFactory
16 *
17 * @category System
18 * @package Http
19 * @subpackage Factories
20 * @implements HttpServiceFactoryInterface
21 */
22 class HttpServiceFactory implements HttpServiceFactoryInterface
23 {
24 /**
25 * Creates a new instance of the http service.
26 *
27 * @return HttpServiceInterface
28 */
29 public function createService()
30 {
31 $httpContextFactory = $this->_createAbstractHttpContextFactory();
32 $httpDispatcher = $this->_createHttpDispatcher();
33
34 return MainFactory::create('HttpService', $httpContextFactory, $httpDispatcher);
35 }
36
37
38 /**
39 * Creates and returns a new instance of the environment http view controller registry factory.
40 *
41 * @return EnvironmentHttpViewControllerRegistryFactory
42 */
43 protected function _createAbstractHttpViewControllerRegistryFactory()
44 {
45 return MainFactory::create('EnvironmentHttpViewControllerRegistryFactory');
46 }
47
48
49 /**
50 * Creates and returns a new instance of the environment http context factory.
51 *
52 * @return EnvironmentHttpContextFactory
53 */
54 protected function _createAbstractHttpContextFactory()
55 {
56 return MainFactory::create('EnvironmentHttpContextFactory');
57 }
58
59
60 /**
61 * Creates and returns a new instance of the http dispatcher.
62 *
63 * @return HttpDispatcherInterface
64 */
65 protected function _createHttpDispatcher()
66 {
67 $httpContextReader = $this->_createHttpContextReader();
68 $httpViewControllerFactory = $this->_createHttpViewControllerFactory();
69
70 return MainFactory::create('HttpDispatcher', $httpContextReader, $httpViewControllerFactory);
71 }
72
73
74 /**
75 * Creates and returns a new instance of the http context reader.
76 *
77 * @return HttpContextReaderInterface
78 */
79 protected function _createHttpContextReader()
80 {
81 return MainFactory::create('HttpContextReader');
82 }
83
84
85 /**
86 * Creates and returns a new instance of the http response processor.
87 *
88 * @return HttpResponseProcessorInterface
89 */
90 protected function _createHttpResponseProcessor()
91 {
92 return MainFactory::create('HttpResponseProcessor');
93 }
94
95
96 /**
97 * Creates and returns a new instance of the http view controller factory.
98 *
99 * @return HttpViewControllerFactoryInterface
100 */
101 protected function _createHttpViewControllerFactory()
102 {
103 $httpViewControllerRegistryFactory = $this->_createAbstractHttpViewControllerRegistryFactory();
104 $httpViewControllerRegistry = $httpViewControllerRegistryFactory->create();
105
106 $httpContextReader = $this->_createHttpContextReader();
107 $httpResponseProcessor = $this->_createHttpResponseProcessor();
108
109 return MainFactory::create('HttpViewControllerFactory',
110 $httpViewControllerRegistry,
111 $httpContextReader,
112 $httpResponseProcessor);
113 }
114 }