Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/185846

Change subject: Add constructor to TemplateRegistry
......................................................................

Add constructor to TemplateRegistry

This is split from Id47127f.

Change-Id: I8a89172fbff36f39b0cba3a869b432ca2e640b15
---
M repo/includes/Template/TemplateRegistry.php
1 file changed, 18 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/46/185846/1

diff --git a/repo/includes/Template/TemplateRegistry.php 
b/repo/includes/Template/TemplateRegistry.php
index 4a65e52..6ac9b2a 100644
--- a/repo/includes/Template/TemplateRegistry.php
+++ b/repo/includes/Template/TemplateRegistry.php
@@ -12,32 +12,39 @@
  *
  * @licence GNU GPL v2+
  * @author H. Snater <[email protected]>
+ * @author Thiemo Mättig
  */
 class TemplateRegistry {
-
-       /**
-        * @var array
-        */
-       private $templates;
 
        /**
         * @var TemplateRegistry
         */
        private static $instance;
 
+       /**
+        * @var string[]
+        */
+       private $templates = array();
 
        public static function getDefaultInstance() {
                if ( self::$instance === null ) {
-                       self::$instance = new self();
-                       self::$instance->addTemplates( include( __DIR__ . 
'/../../resources/templates.php' ) );
+                       self::$instance = new self( include( __DIR__ . 
'/../../resources/templates.php' ) );
                }
+
                return self::$instance;
+       }
+
+       /**
+        * @param string[] $templates
+        */
+       function __construct( array $templates = array() ) {
+               $this->addTemplates( $templates );
        }
 
        /**
         * Gets the array containing all templates.
         *
-        * @return array
+        * @return string[]
         */
        public function getTemplates() {
                return $this->templates;
@@ -47,6 +54,7 @@
         * Gets a specific template.
         *
         * @param string $key
+        *
         * @return string
         */
        public function getTemplate( $key ) {
@@ -56,9 +64,9 @@
        /**
         * Adds multiple templates to the store.
         *
-        * @param array $templates
+        * @param string[] $templates
         */
-       public function addTemplates( $templates ) {
+       public function addTemplates( array $templates ) {
                foreach ( $templates as $key => $snippet ) {
                        $this->addTemplate( $key, $snippet );
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a89172fbff36f39b0cba3a869b432ca2e640b15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to