From 5b41ec52f7fd25cc2bfed7979662677098ab2bfc Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Thu, 11 Jun 2015 17:07:56 +0200 Subject: [PATCH] MDL-50561 messages: Add missing __isset magic method --- lib/classes/message/message.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/classes/message/message.php b/lib/classes/message/message.php index 393d0e7527b..f75cce9332f 100644 --- a/lib/classes/message/message.php +++ b/lib/classes/message/message.php @@ -215,6 +215,20 @@ class message { throw new \coding_exception("Invalid property $prop specified"); } + /** + * Magic method to check if property is set. + * + * @param string $prop name of property to check. + * @return bool + * @throws \coding_exception + */ + public function __isset($prop) { + if (in_array($prop, $this->properties)) { + return isset($this->$prop); + } + throw new \coding_exception("Invalid property $prop specified"); + } + /** * This method lets you define content that would be added to the message only for specific message processors. *