public static function resolveContextVariables($value, $object)
    {

        $value = str_replace(
                array('%PATH_BUILD%', '%CONTEXT%', '%REWRITE_BASE%', '%SERVER_NAME%', '%DEVICE_VIEW%', '%DESIGN%', '%DOMAIN%', '%DOMAIN_BASE_URI%', '%DEPLOYMENT_BASE_PATH%'),
                array(PATH_BUILD, ($object instanceof ContextObject?$object->Slug:$_SERVER['CONTEXT']), $_SERVER['REWRITE_BASE'], $_SERVER['SERVER_NAME'], $_SERVER['DEVICE_VIEW'], $_SERVER['DESIGN'], $object->Domain, $object->DomainBaseURI, isset($object->DeploymentBasePath)?$object->DeploymentBasePath:''),
                $value
                );

        $value = preg_replace("/\/[\/]+/", "/", $value);

        return $value;
    }