2424 * @author Tobias Oetterer
2525 */
2626
27- namespace BootstrapComponents ;
27+ namespace MediaWiki \ Extension \ BootstrapComponents ;
2828
2929use MediaWiki \Logger \LoggerFactory ;
3030use MediaWiki \MediaWikiServices ;
@@ -88,27 +88,7 @@ public static function getInstance() {
8888 public function __construct () {
8989 $ this ->applicationStore = [];
9090 $ this ->applicationClassRegister = $ this ->getApplicationClassRegister ();
91- $ this ->getLogger ()->info ( 'ApplicationFactory was build! ' );
92- }
93-
94- /**
95- * @param null|bool|array $componentWhiteList
96- *
97- * @throws MWException cascading {@see \BootstrapComponents\ApplicationFactory::getApplication}
98- *
99- * @return ComponentLibrary
100- */
101- public function getComponentLibrary ( $ componentWhiteList = null ) {
102- return $ this ->getApplication ( 'ComponentLibrary ' , $ componentWhiteList );
103- }
104-
105- /**
106- * @throws MWException cascading {@see \BootstrapComponents\ApplicationFactory::getApplication}
107- *
108- * @return NestingController
109- */
110- public function getNestingController () {
111- return $ this ->getApplication ( 'NestingController ' );
91+ $ this ->getLogger ()->debug ( 'ApplicationFactory was build! ' );
11292 }
11393
11494 /**
@@ -119,7 +99,7 @@ public function getNestingController() {
11999 *
120100 * @return AttributeManager
121101 */
122- public function getNewAttributeManager ( $ validAttributes , $ aliases ) {
102+ public function getNewAttributeManager ( array $ validAttributes , array $ aliases ): AttributeManager {
123103 return new AttributeManager ( $ validAttributes , $ aliases );
124104 }
125105
@@ -133,7 +113,9 @@ public function getNewAttributeManager( $validAttributes, $aliases ) {
133113 *
134114 * @return ModalBuilder
135115 */
136- public function getNewModalBuilder ( $ id , $ trigger , $ content , $ parserOutputHelper ) {
116+ public function getNewModalBuilder (
117+ string $ id , string $ trigger , string $ content , ParserOutputHelper $ parserOutputHelper
118+ ): ModalBuilder {
137119 return new ModalBuilder ( $ id , $ trigger , $ content , $ parserOutputHelper );
138120 }
139121
@@ -148,7 +130,9 @@ public function getNewModalBuilder( $id, $trigger, $content, $parserOutputHelper
148130 *
149131 * @return ParserRequest
150132 */
151- public function getNewParserRequest ( $ argumentsPassedByParser , $ isParserFunction , $ componentName = 'unknown ' ) {
133+ public function getNewParserRequest (
134+ array $ argumentsPassedByParser , bool $ isParserFunction , string $ componentName = 'unknown '
135+ ): ParserRequest {
152136 return new ParserRequest ( $ argumentsPassedByParser , $ isParserFunction , $ componentName );
153137 }
154138
@@ -178,7 +162,7 @@ public function getParserOutputHelper( $parser = null ) {
178162 *
179163 * @return bool
180164 */
181- public function registerApplication ( $ name , $ class ) {
165+ public function registerApplication ( string $ name , string $ class ): bool {
182166 $ application = trim ( $ name );
183167 $ applicationClass = trim ( $ class );
184168 if ( $ application != '' && class_exists ( $ applicationClass ) ) {
@@ -199,7 +183,7 @@ public function registerApplication( $name, $class ) {
199183 *
200184 * @return bool
201185 */
202- public function resetLookup ( $ application = null ) {
186+ public function resetLookup ( ? string $ application = null ): bool {
203187 if ( is_null ( $ application ) ) {
204188 $ this ->applicationStore = [];
205189 return true ;
@@ -218,9 +202,9 @@ public function resetLookup( $application = null ) {
218202 *
219203 * @throws MWException when no class is registered for the requested application or the creation of the object fails.
220204 *
221- * @return mixed| object
205+ * @return object
222206 */
223- protected function getApplication ( $ name ) {
207+ protected function getApplication ( $ name ): object {
224208 if ( isset ( $ this ->applicationStore [$ name ] ) ) {
225209 return $ this ->applicationStore [$ name ];
226210 }
@@ -233,9 +217,11 @@ protected function getApplication( $name ) {
233217 try {
234218 $ objectReflection = new ReflectionClass ( $ this ->applicationClassRegister [$ name ] );
235219 } catch ( \ReflectionException $ e ) {
236- throw new MWException ( 'Error while trying to build application " ' . $ name . '" with class ' . $ this ->applicationClassRegister [$ name ] );
220+ throw new MWException (
221+ 'Error while trying to build application " ' . $ name . '" with class ' . $ this ->applicationClassRegister [$ name ]
222+ );
237223 }
238- $ this ->getLogger ()->info ( 'ApplicationFactory successfully build application ' . $ name );
224+ $ this ->getLogger ()->debug ( 'ApplicationFactory successfully build application ' . $ name );
239225 return $ this ->applicationStore [$ name ] = $ objectReflection ->newInstanceArgs ( $ args );
240226 }
241227
@@ -244,9 +230,8 @@ protected function getApplication( $name ) {
244230 */
245231 protected function getApplicationClassRegister () {
246232 return [
247- 'ComponentLibrary ' => 'BootstrapComponents \\ComponentLibrary ' ,
248- 'NestingController ' => 'BootstrapComponents \\NestingController ' ,
249- 'ParserOutputHelper ' => 'BootstrapComponents \\ParserOutputHelper ' ,
233+ 'NestingController ' => 'MediaWiki \\Extension \\BootstrapComponents \\NestingController ' ,
234+ 'ParserOutputHelper ' => 'MediaWiki \\Extension \\BootstrapComponents \\ParserOutputHelper ' ,
250235 ];
251236 }
252237
0 commit comments