jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405289 )

Change subject: Add new ExtensionAttributeBasedRegistry and IRegistry
......................................................................


Add new ExtensionAttributeBasedRegistry and IRegistry

Change-Id: Iff270ba3104a548c91c24fa2ff1ee7f862d7748d
---
A src/ExtensionAttributeBasedRegistry.php
A src/IRegistry.php
2 files changed, 66 insertions(+), 0 deletions(-)

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



diff --git a/src/ExtensionAttributeBasedRegistry.php 
b/src/ExtensionAttributeBasedRegistry.php
new file mode 100644
index 0000000..c02f30e
--- /dev/null
+++ b/src/ExtensionAttributeBasedRegistry.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace BlueSpice;
+
+use ExtensionRegistry;
+
+class ExtensionAttributeBasedRegistry implements IRegistry {
+
+       /**
+        *
+        * @var string
+        */
+       protected $attribName = '';
+
+       /**
+        *
+        * @var ExtensionRegistry
+        */
+       protected $extensionRegistry = null;
+
+       /**
+        *
+        * @param string $attribName
+        * @param ExtensionRegistry $extensionRegistry
+        */
+       public function __construct( $attribName, $extensionRegistry = null ) {
+               $this->attribName = $attribName;
+               $this->extensionRegistry = $extensionRegistry;
+               if( $this->extensionRegistry === null ) {
+                       $this->extensionRegistry = 
\ExtensionRegistry::getInstance();
+               }
+       }
+
+       /**
+        *
+        * @param string $key
+        * @param string $default
+        * @return string
+        */
+       public function getValue( $key, $default = '' ) {
+               $registry = $this->extensionRegistry->getAttribute( 
$this->attribName );
+               $value = isset( $registry[$key] ) ? $registry[$key] : $default;
+
+               if( is_array( $value ) ) {
+                       //Attributes get merged together instead of being 
overwritten,
+                       //so just take the last one
+                       $value = end( $value );
+               }
+
+               return (string)$value;
+       }
+}
\ No newline at end of file
diff --git a/src/IRegistry.php b/src/IRegistry.php
new file mode 100644
index 0000000..c92da46
--- /dev/null
+++ b/src/IRegistry.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace BlueSpice;
+
+interface IRegistry {
+
+       /**
+        *
+        * @param string $key
+        * @param string $default
+        * @return string
+        */
+       public function getValue( $key, $default = '' );
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/405289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iff270ba3104a548c91c24fa2ff1ee7f862d7748d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to