1 | <?php |
||
38 | class Builder implements SingletonInterface |
||
39 | { |
||
40 | /** |
||
41 | * @var ExtensionConfiguration |
||
42 | */ |
||
43 | private $extensionConfiguration; |
||
44 | /** |
||
45 | * @var ObjectManagerInterface |
||
46 | */ |
||
47 | private $objectManager; |
||
48 | |||
49 | /** |
||
50 | * @param ExtensionConfiguration $extensionConfiguration |
||
51 | * @param ObjectManagerInterface $objectManager |
||
52 | */ |
||
53 | 10 | public function __construct(ExtensionConfiguration $extensionConfiguration, ObjectManagerInterface $objectManager) |
|
54 | { |
||
55 | 10 | $this->extensionConfiguration = $extensionConfiguration; |
|
56 | 10 | $this->objectManager = $objectManager; |
|
57 | 10 | } |
|
58 | |||
59 | /** |
||
60 | * initialize and configure restler-framework and return restler-object |
||
61 | * |
||
62 | * @return RestlerExtended |
||
63 | */ |
||
64 | public function build() |
||
65 | { |
||
66 | $this->setAutoLoading(); |
||
67 | $this->setCacheDirectory(); |
||
68 | $this->setServerConfiguration(); |
||
69 | |||
70 | $restlerObj = $this->createRestlerObject(); |
||
71 | $this->configureRestler($restlerObj); |
||
72 | $this->addApiClassesByGlobalArray($restlerObj); |
||
73 | return $restlerObj; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @return RestlerExtended |
||
78 | */ |
||
79 | 1 | protected function createRestlerObject() |
|
80 | { |
||
81 | 1 | return new RestlerExtended( |
|
82 | 1 | $this->objectManager->get('Aoe\\Restler\\System\\TYPO3\\Cache'), |
|
83 | 1 | $this->extensionConfiguration->isProductionContextSet(), |
|
84 | 1 | $this->extensionConfiguration->isCacheRefreshingEnabled() |
|
85 | 1 | ); |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * Call all classes, which implements the interface 'Aoe\Restler\System\Restler\ConfigurationInterface'. |
||
90 | * Those classes includes further restler-configurations, e.g.: |
||
91 | * - add API-classes |
||
92 | * - add authentication-classes |
||
93 | * - configure/set properties of several classes inside the restler-framework |
||
94 | * - configure overwriting of several classes inside the restler-framework |
||
95 | * |
||
96 | * @param RestlerExtended $restler |
||
97 | * @throws InvalidArgumentException |
||
98 | */ |
||
99 | 5 | private function configureRestler(RestlerExtended $restler) |
|
134 | |||
135 | /** |
||
136 | * Add API-Controller-Classes that are registered by global array |
||
137 | * |
||
138 | * @param RestlerExtended $restler |
||
139 | */ |
||
140 | 1 | private function addApiClassesByGlobalArray(RestlerExtended $restler) |
|
152 | |||
153 | /** |
||
154 | * use auto-loading for PHP-classes of restler-framework and extBase/TYPO3 (use dependency-injection of extBase) |
||
155 | */ |
||
156 | 1 | private function setAutoLoading() |
|
170 | |||
171 | /** |
||
172 | * configure cache-directory (where restler can write cache-files) |
||
173 | */ |
||
174 | 1 | private function setCacheDirectory() |
|
178 | |||
179 | /** |
||
180 | * fix server-port (if not correct set) |
||
181 | */ |
||
182 | 1 | private function setServerConfiguration() |
|
190 | } |
||
191 |