[MediaWiki-commits] [Gerrit] mediawiki...BlueSpiceFoundation[master]: BSFoudation: Client side config rendering

2017-12-01 Thread Robert Vogel (Code Review)
Robert Vogel has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/394083 )

Change subject: BSFoudation: Client side config rendering
..


BSFoudation: Client side config rendering

* used MediaWikiServices for the new ConfigDefinitionFactory
* added a getter for services to the hook handler base class
* fixed reference for ResourceLoaderGetConfigVars base class
* added method isRLConfigVar to config definition to decide wich config gets 
handed over to the resourceLoader

Change-Id: Icb809c8397d7dc1abe2544ac8f20c77c021240ad
---
M includes/ServiceWiring.php
M src/ConfigDefinition.php
M src/ConfigDefinition/FileExtensions.php
M src/ConfigDefinition/ImageExtensions.php
A src/ConfigDefinitionFactory.php
M src/Hook.php
M src/Hook/ResourceLoaderGetConfigVars.php
M src/Hook/ResourceLoaderGetConfigVars/AddBSGConfig.php
8 files changed, 130 insertions(+), 52 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index 865a084..653b764 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -4,6 +4,12 @@
 
 return [
 
+   'BSConfigDefinitionFactory' => function ( MediaWikiServices $services ) 
{
+   return new \BlueSpice\ConfigDefinitionFactory(
+   $services->getConfigFactory()->makeConfig( 'bsg' )
+   );
+   },
+
'BSDynamicFileDispatcherFactory' => function ( MediaWikiServices 
$services ) {
return new \BlueSpice\DynamicFileDispatcher\Factory(
$services->getConfigFactory()->makeConfig( 'bsg' )
diff --git a/src/ConfigDefinition.php b/src/ConfigDefinition.php
index 41d7002..ad10069 100644
--- a/src/ConfigDefinition.php
+++ b/src/ConfigDefinition.php
@@ -4,8 +4,6 @@
 
 abstract class ConfigDefinition implements ISetting {
 
-   protected static $configDefinitions = null;
-
/**
 *
 * @var \IContextSource
@@ -30,55 +28,10 @@
 * @param \Config $config
 * @param string $name
 */
-   protected function __construct( $context, $config, $name ) {
+   public function __construct( $context, $config, $name ) {
$this->context = $context;
$this->config = $config;
$this->name = $name;
-   }
-
-   /**
-*
-* @param string $name
-* @param \Config $config
-* @return ConfigDefinition | false
-*/
-   public static function factory( $name, \Config $config = null ) {
-   if( !$config ) {
-   $config = \MediaWiki\MediaWikiServices::getInstance()
-   ->getConfigFactory()->makeConfig( 'bsg' );
-   }
-   if( empty( $name ) || !$config->has( $name ) ) {
-   return false;
-   }
-   $definitions = static::getConfigDefinitions();
-   if( !isset( $definitions[$name] ) ) {
-   return false;
-   }
-   if( !is_callable( $definitions[$name] ) ) {
-   return false;
-   }
-   return call_user_func_array( $definitions[$name], [
-   \RequestContext::getMain(),
-   $config,
-   $name,
-   ]);
-   }
-
-   protected static function getConfigDefinitions() {
-   if( static::$configDefinitions ) {
-   return static::$configDefinitions;
-   }
-   static::$configDefinitions = [];
-   foreach( $GLOBALS['bsgExtensions'] as $extName => 
$extDefinition ) {
-   if( empty( $extDefinition['configDefinitions'] ) ) {
-   continue;
-   }
-   static::$configDefinitions = array_merge(
-   static::$configDefinitions,
-   $extDefinition['configDefinitions']
-   );
-   }
-   return static::$configDefinitions;
}
 
/**
@@ -138,10 +91,22 @@
];
}
 
+   /**
+* Returns if the config is stored in the database
+* @return boolean
+*/
public function isStored() {
return false;
}
 
+   /**
+* Returns if the config is a ResourceLoader variable
+* @return boolean
+*/
+   public function isRLConfigVar() {
+   return false;
+   }
+
protected function makeFormFieldParams() {
return [
'name' => $this->getName(),
diff --git a/src/ConfigDefinition/FileExtensions.php 
b/src/ConfigDefinition/FileExtensions.php
index be65e21..f599125 100644
--- a/src/ConfigDefinition/FileExtensio

[MediaWiki-commits] [Gerrit] mediawiki...BlueSpiceFoundation[master]: BSFoudation: Client side config rendering

2017-11-29 Thread Pwirth (Code Review)
Pwirth has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394083 )

Change subject: BSFoudation: Client side config rendering
..

BSFoudation: Client side config rendering

* used MediaWikiServices for the new ConfigDefinitionFactory
* added a getter for services to the hook handler base class
* fixed reference for ResourceLoaderGetConfigVars base class
* added method isRLConfigVar to config definition to decide wich config gets 
handed over to the resourceLoader

Change-Id: Icb809c8397d7dc1abe2544ac8f20c77c021240ad
---
M includes/ServiceWiring.php
M src/ConfigDefinition.php
M src/ConfigDefinition/FileExtensions.php
M src/ConfigDefinition/ImageExtensions.php
A src/ConfigDefinitionFactory.php
M src/Hook.php
M src/Hook/ResourceLoaderGetConfigVars.php
M src/Hook/ResourceLoaderGetConfigVars/AddBSGConfig.php
8 files changed, 130 insertions(+), 52 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/83/394083/3

diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index 865a084..653b764 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -4,6 +4,12 @@
 
 return [
 
+   'BSConfigDefinitionFactory' => function ( MediaWikiServices $services ) 
{
+   return new \BlueSpice\ConfigDefinitionFactory(
+   $services->getConfigFactory()->makeConfig( 'bsg' )
+   );
+   },
+
'BSDynamicFileDispatcherFactory' => function ( MediaWikiServices 
$services ) {
return new \BlueSpice\DynamicFileDispatcher\Factory(
$services->getConfigFactory()->makeConfig( 'bsg' )
diff --git a/src/ConfigDefinition.php b/src/ConfigDefinition.php
index 41d7002..ad10069 100644
--- a/src/ConfigDefinition.php
+++ b/src/ConfigDefinition.php
@@ -4,8 +4,6 @@
 
 abstract class ConfigDefinition implements ISetting {
 
-   protected static $configDefinitions = null;
-
/**
 *
 * @var \IContextSource
@@ -30,55 +28,10 @@
 * @param \Config $config
 * @param string $name
 */
-   protected function __construct( $context, $config, $name ) {
+   public function __construct( $context, $config, $name ) {
$this->context = $context;
$this->config = $config;
$this->name = $name;
-   }
-
-   /**
-*
-* @param string $name
-* @param \Config $config
-* @return ConfigDefinition | false
-*/
-   public static function factory( $name, \Config $config = null ) {
-   if( !$config ) {
-   $config = \MediaWiki\MediaWikiServices::getInstance()
-   ->getConfigFactory()->makeConfig( 'bsg' );
-   }
-   if( empty( $name ) || !$config->has( $name ) ) {
-   return false;
-   }
-   $definitions = static::getConfigDefinitions();
-   if( !isset( $definitions[$name] ) ) {
-   return false;
-   }
-   if( !is_callable( $definitions[$name] ) ) {
-   return false;
-   }
-   return call_user_func_array( $definitions[$name], [
-   \RequestContext::getMain(),
-   $config,
-   $name,
-   ]);
-   }
-
-   protected static function getConfigDefinitions() {
-   if( static::$configDefinitions ) {
-   return static::$configDefinitions;
-   }
-   static::$configDefinitions = [];
-   foreach( $GLOBALS['bsgExtensions'] as $extName => 
$extDefinition ) {
-   if( empty( $extDefinition['configDefinitions'] ) ) {
-   continue;
-   }
-   static::$configDefinitions = array_merge(
-   static::$configDefinitions,
-   $extDefinition['configDefinitions']
-   );
-   }
-   return static::$configDefinitions;
}
 
/**
@@ -138,10 +91,22 @@
];
}
 
+   /**
+* Returns if the config is stored in the database
+* @return boolean
+*/
public function isStored() {
return false;
}
 
+   /**
+* Returns if the config is a ResourceLoader variable
+* @return boolean
+*/
+   public function isRLConfigVar() {
+   return false;
+   }
+
protected function makeFormFieldParams() {
return [
'name' => $this->getName(),
diff --git a/src/ConfigDefinition/FileExtensions.php 
b/src/ConfigDefinition/FileExtensions.php
index be65e21..f599125 100644
--- a/src/ConfigDefi