r106528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106527‎ | r106528 | r106529 >
Date:20:18, 17 December 2011
Author:catrope
Status:ok
Tags:
Comment:
[RL2] Add Gadget::getPropertiesBase() to simplify building Gadget objects in tests
Modified paths:
  • /branches/RL2/extensions/Gadgets/backend/Gadget.php (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/backend/Gadget.php
@@ -63,7 +63,32 @@
6464
6565 /*** Public static methods ***/
6666
 67+ // Would like to do const PROPERTIES_BASE = array( ... ); here, but:
 68+ // Fatal error: Arrays are not allowed in class constants
 69+ // public static final $propertiesBase also doesn't work, so:
6770 /**
 71+ * Get the array representation of an empty gadget.
 72+ * This would have been a constant or something if PHP hadn't sucked
 73+ */
 74+ public static function getPropertiesBase() {
 75+ return array(
 76+ 'settings' => array(
 77+ 'rights' => array(),
 78+ 'default' => false,
 79+ 'hidden' => false,
 80+ 'shared' => false,
 81+ 'category' => '',
 82+ ),
 83+ 'module' => array(
 84+ 'scripts' => array(),
 85+ 'styles' => array(),
 86+ 'dependencies' => array(),
 87+ 'messages' => array(),
 88+ ),
 89+ );
 90+ }
 91+
 92+ /**
6893 * Check the validity of the given properties array
6994 * @param $properties Return value of FormatJson::decode( $blob, true )
7095 * @return Status object with error message if applicable

Status & tagging log