From d129b1eed574cec2276d6cefe9261ed6b2c7ddac Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 17 May 2016 21:40:05 +0200 Subject: Implement TControl::__isset() to check for sub controls Fix #594 --- HISTORY | 2 +- framework/Web/UI/TControl.php | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index 90194aed..8482c526 100644 --- a/HISTORY +++ b/HISTORY @@ -3,9 +3,9 @@ Version 3.3.2 xxx, 2016 BUG: Issue #592 - Fix TActiveMultiView brokwn on 3.3.1 (ctrlaltca) BUG: Issue #588 - Fix reading values of controls inside TJuiDialog (ctrlaltca) ENH: Issue #591 - Support for hyphenated attributes via template syntax (emkael) +ENH: Issue #594 - Added ability to check for subcontrols using isset(), empty() (jojoinside) ENH: Allow TStyle behaviors (LCSKJ) - Version 3.3.1 April 19, 2016 BUG: Issue #540 - Fix TActiveFileUpload on IE11 (ctrlaltca) 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 @@ -195,6 +195,31 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable return parent::__get($name); } + /** + * 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, + * + * $menuBarExists = isset($this->menuBar); + * + * 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 */ -- cgit v1.2.3