function _getPropertyDescriptors($class) { global $_classPropertyDescriptorsCache; if (!isset($this->_propertyDescriptors[$class])) { if (isset($_classPropertyDescriptorsCache[$class])) { $this->_propertyDescriptors[$class] =& $_classPropertyDescriptorsCache[$class]; } else { $classInfoClass = $class . 'ClassInfo'; $propertyDescriptors = call_user_func(array($classInfoClass, 'getPropertyDescriptors')); if ($propertyDescriptors === false) { if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, 'SQLMapper: Cannot convert "' . $class . '" objects without ClassInfo definition.'); } } else { $this->_propertyDescriptors[$class] = array(); foreach ((array) $propertyDescriptors as $propDescriptor) { $name = $propDescriptor->getPropertyName(); $this->_propertyDescriptors[$class][$name] = $propDescriptor; } $_classPropertyDescriptorsCache[$class] = $this->_propertyDescriptors[$class]; } } } return $this->_propertyDescriptors[$class]; }
function log_exception($severity, $message, $filepath, $line) { $log_level = !isset($this->_level_log_map[$severity]) ? LOG_DEBUG : $this->_level_log_map[$severity]; if (function_exists('log_enabled') && log_enabled($log_level)) { $severity = !isset($this->_levels[$severity]) ? $severity : $this->_levels[$severity]; log_message($log_level, 'Severity: ' . $severity . ' --> ' . $message . ' ' . $filepath . ' ' . $line); } }
function render(&$model, &$request, &$response) { if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Rendering view with name '" . $this->serviceName . "' with model " . var_export($model, true) . " and static attributes " . var_export($this->staticAttributes, true)); } // Consolidate static and dynamic model attributes. $mergedModel = array_merge($this->staticAttributes, $model); return $this->renderMergedOutputModel($mergedModel, $request, $response); }
function &handleRequestInternal(&$request, &$response) { $lookupPath = $request->getContextPath(); $viewName = $this->getViewNameForRequest(&$request); if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Returning view name '" . $viewName . "' for lookup path [" . $lookupPath . "]"); } $mv =& new ModelAndView($viewName); return $mv; }
function _detectHandlers() { if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Looking for URL mappings in application context"); } $service_points =& AppContext::getServicePoints(); foreach ($service_points as $name => $point) { $urls = $this->_determineUrlsForServicePoint($point); if (!empty($urls)) { foreach ($urls as $url) { $this->registerHandler($url, $name); } } else { if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Rejected service point '" . $name . "': no URL paths identified"); } } } }
function invokeValidator(&$validator, &$obj, &$bindingResult) { assert_not_null($validator, "Validator must not be null"); assert_not_null($bindingResult, "BindingResult object must not be null"); if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Invoking validator [" . get_class($validator) . "]"); } if ($obj != null && $validator->supports(get_class($obj)) != true) { show_error('Validator', "Validator " . get_class($validator) . " does not support " . get_class($obj)); } $currentCount = $bindingResult->getErrorCount(); $validator->validate(&$obj, &$bindingResult); if (log_enabled(LOG_DEBUG)) { if ($bindingResult->hasErrors()) { $thisCount = $bindingResult->getErrorCount() - $currentCount; log_message(LOG_DEBUG, "Validator found " . $thisCount . " errors"); } else { log_message(LOG_DEBUG, "Validator found no errors"); } } }
function _render(&$mv, &$request, &$response) { $view = null; // Do we need view name translation? if (!$mv->hasView()) { $mv->view =& $this->_getDefaultViewName($request); } if ($mv->viewIsReference()) { // We need to resolve the view name. $view =& $this->_resolveViewName($mv->getViewName(), $request->locale, &$request); if ($view == null) { show_error('Dispatcher Error', 'Could not resolve view with name "' . $mv->getViewName() . '"'); } } else { // No need to lookup: the ModelAndView object contains the actual View object. $view =& $mv->getView(); if ($view == null) { show_error('Dispatcher Error', 'ModelAndView lacks a view name or a View Object'); } } // Delegate to the View object for rendering. if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Rendering view [" . get_class($view) . "]"); } return $view->render($mv->getModel(), &$request, &$response); }
function checkAllowedFields(&$nvps) { foreach ((array) $nvps as $name => $value) { $field = BeanWrapperUtils::canonicalPropertyName($name); if (!$this->isAllowed($field)) { unset($nvps[$name]); $br =& $this->getBindingResult(); $br->recordSuppressedField($field); if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Field [" . $field . "] has been removed from the nvps array " . "and will not be bound, because it has not been found in the list of allowed fields"); } } } }
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 . "]"); } } } }
function &showFormSupport(&$request, &$bindingResult, $viewName, $controlModel = null) { // In session form mode, re-expose form object as HTTP session attribute. // Re-binding is necessary for proper state handling in a cluster, // to notify other nodes of changes in the form object. if ($this->isSessionForm() === true) { $formAttrName = $this->getFormSessionAttributeName(&$request); if (log_enabled(LOG_DEBUG)) { log_message(LOG_DEBUG, "Setting form session attribute [" . $formAttrName . "] to: " . get_class($bindingResult->getTarget())); } $session =& $request->getSession(); $session->setAttribute($formAttrName, $bindingResult->getTarget()); } // Fetch errors model as starting point, containing form object under // "commandName", and corresponding Errors instance under internal key. $model =& $bindingResult->getModel(); // Merge reference data into model, if any. $referenceData = $this->referenceData(&$request, $bindingResult->getTarget(), $bindingResult); if ($referenceData != null) { $model = array_merge($model, $referenceData); } // Merge control attributes into model, if any. if ($controlModel != null) { $model = array_merge($model, $controlModel); } // Trigger rendering of the specified view, using the final model. $mv =& new ModelAndView($viewName, &$model); return $mv; }
function &getPropertyValue($tokens) { // not a PropertyTokenHolder, assume just a propertyName if (strtolower(get_class($tokens)) != 'propertytokenholder') { $nestedBw =& $this->_getBeanWrapperForPropertyPath($tokens); if (strtolower(get_class($nestedBw)) != 'beanwrapper') { return $nestedBw; } $tokens =& $this->_getPropertyNameTokens($this->_getFinalPath($nestedBw, $tokens)); return $nestedBw->getPropertyValue($tokens); } $propertyName = $tokens->canonicalName; $actualName = $tokens->actualName; $pd =& $this->_getPropertyDescriptorInternal($tokens->actualName); if (is_null($pd)) { $ex =& new NotReadablePropertyException($this->getRootClass(), $this->nestedPath . $propertyName, 'Cannot get PropertyDescriptor for property: ' . $this->nestedPath . $propertyName); return $ex; } $readMethod = 'get' . $pd->getPropertyName(); if (log_enabled(LOG_INFO)) { log_message(LOG_INFO, "About to invoke read method [" . $readMethod . "] on object of class [" . get_class($this->object) . "]"); } if (!method_exists($this->object, $readMethod)) { $ex =& new InvalidPropertyException($this->getRootClass(), $this->nestedPath . $propertyName, 'Object of type ' . get_class($this->object) . ' must have get method: ' . $readMethod); return $ex; } $value =& $this->object->{$readMethod}(); if ($tokens->keys != null && !empty($tokens->keys)) { if (is_null($value)) { $ex =& new NullValueInNestedPathException($this->getRootClass(), $this->nestedPath . $propertyName, "Cannot access indexed value of property referenced in indexed " . "property path '" . $propertyName . "': returned null"); return $ex; } // apply indexes and map keys foreach ((array) $tokens->keys as $key) { if (is_array($value)) { if (!isset($value[$key])) { $ex =& new InvalidPropertyException($this->getRootClass(), $this->nestedPath . $propertyName, "Index of [{$key}] out of bounds in property path '{$propertyName}'"); return $ex; } $value =& $value[$key]; } else { $ex =& new InvalidPropertyException($this->getRootClass(), $this->nestedPath . $propertyName, "Property referenced in indexed property path '" . $propertyName . "' is not an array; returned value was [" . var_export($value, true) . "]"); return $ex; } } } return $value; }