/**
  * This function attempts to require the class corresponding to the specified relative class path.
  * If the class has already been loaded, it will not load it again.
  * @param String $classPath The path of the class to be loaded.
  * @return void
  */
 public static function requireClassOnce($classPath)
 {
     // if the specified class path hasn't already been loaded, attempt to load it
     if (!isset(ClassLoader::$loadedClassPaths[$classPath])) {
         $className = ClassLoader::parseClassName($classPath);
         ClassLoader::$loadedClassPaths[$classPath] = TRUE;
         require dirname(dirname(__FILE__)) . "/{$classPath}.class.php";
     }
 }
 /**
  * This method formats a URL for the specified routing item class name, incorporating
  * the get parameters specified in the get parameter map.
  * @param String $routingItemClassPath The class path of the target routing item.
  * @param array $getParamMap A map of get parameters to be included in the URL (optional).
  * @return String The formatted URL.
  */
 public static function formatRoutingItemUrl($routingItemClassPath, array $getParamMap = NULL)
 {
     ClassLoader::requireClassOnce($routingItemClassPath);
     $routingClassName = ClassLoader::parseClassName($routingItemClassPath);
     $url = UrlFormatter::getBaseUrl() . '?' . IndexRoutingItem::INDEX_ROUTING_ITEM_GET_PARAM . '=';
     $url .= $routingClassName::getRoutingKey();
     if ($getParamMap != NULL) {
         foreach ($getParamMap as $key => $value) {
             $url .= "&{$key}={$value}";
         }
     }
     return $url;
 }
Example #3
0
/**
 * This function loads and maps the index routing item which corresponds to the specified action class path into
 * the specified index routing item map.
 * @param String $classPath The class path of the index routing item to be loaded.
 * @param array &$indexRoutingItemMap A reference to the index routing item map which the loaded action
 * will be mapped into.
 * @return IndexRoutingItem The index routing item which was created.
 */
function loadAndMapIndexRoutingItem($classPath, array &$indexRoutingItemMap)
{
    ClassLoader::requireClassOnce($classPath);
    $className = ClassLoader::parseClassName($classPath);
    $newIndexRoutingItem = new $className();
    $indexRoutingItemMap[$className::getRoutingKey()] = $newIndexRoutingItem;
    return $newIndexRoutingItem;
}