/** * Method is called before setting the field and verifies that, if it is a string, * it contains a JSON array. * @method beforeSet_permissions * @param {string} $value * @return {array} An array of field name and value * @throws {Exception} An exception is thrown if $value is not string or is exceedingly long */ function beforeSet_permissions($value) { if (is_string($value)) { $decoded = Q::json_decode($value, true); if (!is_array($decoded) or Q::isAssociative($decoded)) { throw new Q_Exception_WrongValue(array('field' => 'permissions', 'range' => 'JSON array')); } } return parent::beforeSet_permissions($value); }