summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2016-05-17 21:40:05 +0200
committerFabio Bas <ctrlaltca@gmail.com>2016-05-17 21:40:05 +0200
commitd129b1eed574cec2276d6cefe9261ed6b2c7ddac (patch)
tree13d4414ddf235be8a373f6f41d3bdd23e0cf4150 /framework/Web/UI
parent01d8270370557699bdda9f420b64fef9aff36339 (diff)
Implement TControl::__isset() to check for sub controls
Fix #594
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/TControl.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index be7b1185..1b8a2138 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -196,6 +196,31 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
}
/**
+ * Checks for the existance of a property value by name or a control by ID.
+ * This overrides the parent implementation by allowing checking for the
+ * existance of a control via its ID using the following syntax,
+ * <code>
+ * $menuBarExists = isset($this->menuBar);
+ * </code>
+ * Do not call this method. This is a PHP magic method that we override
+ * to allow using isset() to detect if a component property is set or not.
+ * Note, the control must be configured in the template
+ * with explicit ID. If the name matches both a property and a control ID,
+ * the control ID will take the precedence.
+ *
+ * @param string the property name or control ID
+ * @return bool wether the control or property exists
+ * @see __get
+ */
+ public function __isset($name) {
+ if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) {
+ return true;
+ } else {
+ return parent::__isset($name);
+ }
+ }
+
+ /**
* @return boolean whether there is an adapter for this control
*/
public function getHasAdapter()