ensure accessing a cell on ref update
[m6w6/pq-gateway] / lib / pq / Gateway / Row.php
index 6d9c19e750b1b215da48b1b90959692f3f6c9fd8..cda8d4af67a0ba857a6854b4f8c262f016f5e34d 100644 (file)
@@ -184,6 +184,18 @@ class Row implements \JsonSerializable
                return $changes;
        }
        
+       /**
+        * Cell accessor
+        * @param string $p column name
+        * @return \pq\Gateway\Cell
+        */
+       protected function cell($p) {
+               if (!isset($this->cell[$p])) {
+                       $this->cell[$p] = new Cell($this, $p, isset($this->data[$p]) ? $this->data[$p] : null);
+               }
+               return $this->cell[$p];
+       }
+       
        /**
         * Get a cell or parent rows
         * @param string $p
@@ -193,10 +205,7 @@ class Row implements \JsonSerializable
                if ($this->table->hasRelation($p)) {
                        return $this->table->by($this, $p);
                }
-               if (!isset($this->cell[$p])) {
-                       $this->cell[$p] = new Cell($this, $p, isset($this->data[$p]) ? $this->data[$p] : null);
-               }
-               return $this->cell[$p];
+               return $this->cell($p);
        }
        
        /**
@@ -205,7 +214,7 @@ class Row implements \JsonSerializable
         * @param mixed $v
         */
        function __set($p, $v) {
-               $this->__get($p)->set($v);
+               $this->cell($p)->set($v);
        }
        
        /**