Cscott has uploaded a new change for review.

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

Change subject: Element.php: Add "data" property
......................................................................

Element.php: Add "data" property

This makes the PHP API match the JS API.  The Element data isn't terribly
useful on the PHP side at the moment, but after T74716 allows us to
create JS widgets corresponding to PHP widgets this will allow us to
pass information from server-side to client-side.

Change-Id: I5261784081cb395747b2f5289b53baf2b7f50d3f
---
M php/Element.php
1 file changed, 31 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/43/191243/1

diff --git a/php/Element.php b/php/Element.php
index 35ab53a..f327154 100644
--- a/php/Element.php
+++ b/php/Element.php
@@ -32,6 +32,13 @@
        /* Members */
 
        /**
+        * Element data.
+        *
+        * @var mixed
+        */
+       protected $data = null;
+
+       /**
         * Mixins.
         *
         * @var array List mixed in objects.
@@ -46,12 +53,16 @@
         * @param string $config['id'] HTML id attribute
         * @param array $config['content'] Content to append, strings or 
Element objects. Strings will
         *   be HTML-escaped for output, use a HtmlSnippet instance to prevent 
that.
+        * @param Mixed $config['data'] Element data
         */
        public function __construct( array $config = array() ) {
                // Parent constructor
                parent::__construct( $this->getTagName() );
 
                // Initialization
+               if ( isset( $config['data'] ) ) {
+                       $this->setData( $config['data'] );
+               }
                if ( isset( $config['classes'] ) && is_array( 
$config['classes'] ) ) {
                        $this->addClasses( $config['classes'] );
                }
@@ -124,6 +135,26 @@
        }
 
        /**
+        * Get element data.
+        *
+        * @return {Mixed} Element data
+        */
+       public function getData() {
+               return $this->data;
+       }
+
+       /**
+        * Set element data.
+        *
+        * @param {Mixed} Element data
+        * @chainable
+        */
+       public function setData( $data ) {
+               $this->data = $data;
+               return $this;
+       }
+
+       /**
         * Check if element supports one or more methods.
         *
         * @param string|string[] $methods Method or list of methods to check

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5261784081cb395747b2f5289b53baf2b7f50d3f
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>

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

Reply via email to