Esempio n. 1
0
 function DataBinder(&$target, $objectName = DEFAULT_OBJECT_NAME)
 {
     assert_not_null($target, 'DataBinder: target must not be null');
     $this->target =& $target;
     $this->objectName =& $objectName;
     $this->bindingErrorProcessor =& new BindingErrorProcessor();
 }
Esempio n. 2
0
 function PropertyDescriptor($propertyName, $propertyType, $propertyEditor = null)
 {
     assert_not_null($propertyName, 'PropertyDescriptor: propertyName must not be null');
     assert_not_null($propertyType, 'PropertyDescriptor: propertyType must not be null');
     $this->propertyName =& $propertyName;
     $this->propertyType =& $propertyType;
     $this->propertyEditor =& $propertyEditor;
 }
Esempio n. 3
0
 function BindingResult(&$target, &$objectName)
 {
     assert_not_null($target, 'Target must not be null');
     assert_not_null($objectName, 'Object name must not be null');
     $this->objectName =& $objectName;
     $this->target =& $target;
     $this->messageCodesResolver =& new MessageCodesResolver();
 }
Esempio n. 4
0
 function FieldError(&$objectName, &$field, &$rejectedValue, $bindingFailure, &$codes, $arguments = null, $defaultMessage = null)
 {
     parent::ObjectError($objectName, $codes, $arguments, $defaultMessage);
     assert_not_null($field, 'Field must not be null');
     $this->field =& $field;
     $this->rejectedValue =& $rejectedValue;
     $this->bindingFailure =& $bindingFailure;
 }
Esempio n. 5
0
 function loadTextDomains(&$locale)
 {
     assert_not_null($locale, 'cannot load text domains: locale is null');
     $variant = $locale->variant;
     foreach ($this->textDomains as $domain => $path) {
         $mofile = "{$path}/{$domain}-{$variant}.mo";
         $this->_loadTextReader($domain, $mofile);
     }
 }
Esempio n. 6
0
 function rejectIfEmptyOrWhitespace(&$bindingResult, $field, $errorCode, $errorArgs = null, $defaultMessage = null)
 {
     assert_not_null($bindingResult, "BindingResult object must not be null");
     $value = $bindingResult->getFieldValue($field);
     if ($value == null || strlen(trim($value)) == 0) {
         $bindingResult->rejectValue($field, $errorCode, $errorArgs, $defaultMessage);
         return false;
     }
     return true;
 }
Esempio n. 7
0
 function getBindingResult(&$model, $name)
 {
     assert_not_null($model, "Model map must not be null");
     assert_not_null($name, "Name must not be null");
     $attrname = BINDING_RESULT_MODEL_KEY_PREFIX . $name;
     $attr = $model[$attrname];
     if ($attr != null && !is_a($attr, 'BindingResult')) {
         show_error('Illegal State', "BindingResult attribute is not of type BindingResult: " . $attr);
     }
     return $attr;
 }
Esempio n. 8
0
 function &mapArrayToObject($array, $class)
 {
     assert_not_null($array, 'SQLMapper::mapArrayToObject : array cannot be null');
     assert_not_null($class, 'SQLMapper::mapArrayToObject : class cannot be null');
     if (!isset($this->sqlMaps[$class])) {
         show_error('SQLMapper', 'No SQLmap found for class: ' . $class);
     }
     $obj =& new $class();
     $propertyDescriptors = $this->_getPropertyDescriptors($class);
     $propertyMap = $this->sqlMaps[$class];
     foreach ($propertyMap as $dbColumn => $objectProperty) {
         if (isset($propertyDescriptors[$objectProperty])) {
             $propDescriptor = $propertyDescriptors[$objectProperty];
         } else {
             continue;
         }
         $datatype = $propDescriptor->getPropertyType();
         switch ($datatype) {
             case 'string':
                 $obj->{$objectProperty} = $this->_getArrayValue($dbColumn, $array);
                 break;
             case 'int':
                 $obj->{$objectProperty} = is_null($this->_getArrayValue($dbColumn, $array)) ? null : intVal($this->_getArrayValue($dbColumn, $array));
                 break;
             case 'float':
                 $obj->{$objectProperty} = is_null($this->_getArrayValue($dbColumn, $array)) ? null : floatVal($this->_getArrayValue($dbColumn, $array));
                 break;
             case 'boolean':
                 $obj->{$objectProperty} = $this->datasource->db->convertBoolean($this->_getArrayValue($dbColumn, $array));
                 break;
             case 'timestamp':
                 $obj->{$objectProperty} = $this->datasource->db->convertTimestamp($this->_getArrayValue($dbColumn, $array));
                 break;
             case 'date':
                 $obj->{$objectProperty} = $this->datasource->db->convertDate($this->_getArrayValue($dbColumn, $array));
                 break;
             case 'time':
                 $obj->{$objectProperty} = $this->datasource->db->convertTime($this->_getArrayValue($dbColumn, $array));
                 break;
             case 'string[]':
                 $obj->{$objectProperty} = explode(',', $this->_getArrayValue($dbColumn, $array));
                 break;
             default:
                 continue;
         }
     }
     return $obj;
 }
Esempio n. 9
0
 function ObjectError(&$objectName, &$codes, $arguments = null, $defaultMessage = null)
 {
     parent::MessageSourceResolvable($codes, $arguments, $defaultMessage);
     assert_not_null($objectName, 'Object name must not be null');
     $this->objectName =& $objectName;
 }
Esempio n. 10
0
 function deletePost(&$post)
 {
     assert_not_null($post->id, 'PostDAO::deletePost: post->id cannot be null');
     $this->datasource->db->delete($this->tableName, array('post_id' => $post->id));
 }
Esempio n. 11
0
 function &_getPropertyDescriptorInternal($propertyName)
 {
     assert_not_null($this->object, 'BeanWrapper does not hold a bean instance');
     assert_not_null($propertyName, "Property name must not be null");
     $nestedBw =& $this->_getBeanWrapperForPropertyPath($propertyName);
     if (strtolower(get_class($nestedBw)) != 'beanwrapper') {
         return _null();
     }
     $propDescriptors =& $nestedBw->getPropertyDescriptors();
     $finalPath = $this->_getFinalPath(&$nestedBw, $propertyName);
     if ($propDescriptors == null || !isset($propDescriptors[$finalPath])) {
         return _null();
     }
     $pd = $propDescriptors[$finalPath];
     return $pd;
 }
Esempio n. 12
0
 public function test_not_null()
 {
     assert_not_null(0);
     assert_fails(function () {
         assert_not_null(null);
     });
 }
Esempio n. 13
0
function option($value, $label = null, $options = array())
{
    global $request;
    $bindStatus =& $request->getAttribute('select_listValue');
    assert_not_null($bindStatus, 'option tag must be used within a select tag');
    $iVal = _get_display_string($value, $bindStatus->getEditor());
    $iLabel = $label == null ? $iVal : $label;
    $options['value'] = $iVal;
    if (SelectedValueComparator::isSelected($bindStatus, $iVal)) {
        $selectedVal = _tag_get_attribute('select', 'selectedVal');
        if ($selectedVal !== true) {
            $options['selected'] = 'selected';
            _tag_set_attribute('select', 'selectedVal', $val = true);
        }
    }
    return content_tag('option', $iLabel, $options);
}
Esempio n. 14
0
function is_assignable($type, $value)
{
    if (is_null($value)) {
        return true;
    }
    assert_not_null($type, 'Function is_assignable: $type must not be null');
    if (!is_string($type)) {
        show_error('is_assignable', '$type must be a string');
    }
    if (is_array_type($type)) {
        //		$array_type = get_array_component_type($type);
        return get_qualified_type($value) == $type;
    }
    switch (strtolower($type)) {
        case 'string':
            if (is_string($value)) {
                return true;
            }
            break;
        case 'int':
            if (is_int($value)) {
                return true;
            }
            break;
        case 'boolean':
            if (is_bool($value)) {
                return true;
            }
            break;
        case 'array':
            if (is_array($value)) {
                return true;
            }
            break;
        case 'float':
            if (is_float($value)) {
                return true;
            }
            break;
        default:
            if (is_object($value) && is_subclass(get_class($value), $type)) {
                return true;
            }
            break;
    }
    return false;
}
 function registerHandler($urlPath, $serviceName)
 {
     assert_not_null($urlPath, 'URL path must not be null');
     assert_not_null($serviceName, 'Service name must not be null');
     if ($urlPath == "/") {
         if (log_enabled(LOG_DEBUG)) {
             log_message(LOG_DEBUG, "Root mapping to handler [" . $serviceName . "]");
         }
         $this->rootHandler = $serviceName;
     } else {
         if ($urlPath == "/*") {
             if (log_enabled(LOG_DEBUG)) {
                 log_message(LOG_DEBUG, "Default mapping to handler [" . $serviceName . "]");
             }
             $this->defaultHandler = $serviceName;
         } else {
             $this->handlerMap[$urlPath] = $serviceName;
             if (log_enabled(LOG_DEBUG)) {
                 log_message(LOG_DEBUG, "Mapped URL path [" . $urlPath . "] onto handler [" . $serviceName . "]");
             }
         }
     }
 }
Esempio n. 16
0
 function &_getHandlerExecutionChain(&$request)
 {
     foreach ($this->handlerMapping as $hm) {
         assert_not_null($hm, 'HandlerMapping was null');
         if (log_enabled(LOG_DEBUG)) {
             log_message(LOG_DEBUG, "Testing handler map [" . get_class($hm) . "]");
         }
         $handler =& $hm->getHandler(&$request);
         if ($handler != null) {
             return $handler;
         }
     }
     return _null();
 }
Esempio n. 17
0
 function hasSubmitParameter(&$request, $name)
 {
     assert_not_null($request, "Request must not be null");
     if ($request->getParameter($name) != null) {
         return true;
     }
     $submit_image_suffixes = array(".x", ".y");
     foreach ($submit_image_suffixes as $suffix) {
         if ($request->getParameter($name . $suffix) != null) {
             return true;
         }
     }
     return false;
 }