public function loadResource($request, $match)
    {
        // First part of path
        $firstPart = $match['firstPart'];
        // Remain part of path
        $remainPart = '';
        if (array_key_exists('remainPart', $match)) {
            $remainPart = $match['remainPart'];
        }

        $spa = Tenant_SPA::getSpaByName($firstPart);
        if (isset($spa)) { // SPA is valid
            $path = $remainPart;
            $spaName = $firstPart;
        } else {
            // first part is not an SPA so use default SPA
            $path = isset($remainPart) && ! empty($remainPart) ? $firstPart . '/' . $remainPart : $firstPart;

            // find a resource
            $tenantResource = $this->findTenantResource('/' . $path);
            if ($tenantResource) {
                return new Pluf_HTTP_Response_File($tenantResource->getAbsloutPath(), $tenantResource->mime_type);
            }

            // [OR] check for default spa
            $name = Tenant_Service::setting('spa.default', 'not-found');
            $spa = Tenant_SPA::getSpaByName($name);
            if ($spa === null) {
                $spa = Tenant_SpaService::getNotfoundSpa();
                $spaName = 'not-found';
            } else {
                $spaName = null;
            }
        }

        if (preg_match('/.+\.[a-zA-Z0-9]+$/', $path)) {
            // Looking for file in SPA
            $resPath = $spa->getResourcePath($path);
            $isMain = false;
        } else {
            // [OR]Request is for main file (path is an internal state)
            $resPath = $spa->getMainPagePath();
            $isMain = true;
        }
        if ($isMain) {
            return new Tenant_HTTP_Response_SpaMain($resPath, Pluf_FileUtil::getMimeType($resPath), $spaName);
        } else {
            return new Pluf_HTTP_Response_File($resPath, Pluf_FileUtil::getMimeType($resPath));
        }
    }
public function loadResource($request, $match)
    {
        // First part of path
        $firstPart = $match['firstPart'];
        // Remain part of path
        $remainPart = '';
        if (array_key_exists('remainPart', $match)) {
            $remainPart = $match['remainPart'];
        }

        $spa = Tenant_SPA::getSpaByName($firstPart);
        if (isset($spa)) { // SPA is valid
            $path = $remainPart;
            $spaName = $firstPart;
        } else {
            // first part is not an SPA so use default SPA
            $path = isset($remainPart) && ! empty($remainPart) ? $firstPart . '/' . $remainPart : $firstPart;

            // find a resource
            $tenantResource = $this->findTenantResource('/' . $path);
            if ($tenantResource) {
                return new Pluf_HTTP_Response_File($tenantResource->getAbsloutPath(), $tenantResource->mime_type);
            }

            // [OR] check for default spa
            $name = Tenant_Service::setting('spa.default', 'not-found');
            $spa = Tenant_SPA::getSpaByName($name);
            if ($spa === null) {
                $spa = Tenant_SpaService::getNotfoundSpa();
                $spaName = 'not-found';
            } else {
                $spaName = null;
            }
        }

        if (preg_match('/.+\.[a-zA-Z0-9]+$/', $path)) {
            // Looking for file in SPA
            $resPath = $spa->getResourcePath($path);
            $isMain = false;
        } else {
            // [OR]Request is for main file (path is an internal state)
            $resPath = $spa->getMainPagePath();
            $isMain = true;
        }
        if ($isMain) {
            return new Tenant_HTTP_Response_SpaMain($resPath, Pluf_FileUtil::getMimeType($resPath), $spaName);
        } else {
            return new Pluf_HTTP_Response_File($resPath, Pluf_FileUtil::getMimeType($resPath));
        }
    }
public function loadResource ( $ request , $ match ) { // First part of path $ firstPart = $ match [ 'firstPart' ] ; // Remain part of path $ remainPart = '' ; if ( array_key_exists ( 'remainPart' , $ match ) ) { $ remainPart = $ match [ 'remainPart' ] ; } $ spa = Tenant_SPA :: getSpaByName ( $ firstPart ) ; if ( isset ( $ spa ) ) { // SPA is valid $ path = $ remainPart ; $ spaName = $ firstPart ; } else { // first part is not an SPA so use default SPA $ path = isset ( $ remainPart ) && ! empty ( $ remainPart ) ? $ firstPart . '/' . $ remainPart : $ firstPart ; // find a resource $ tenantResource = $ this -> findTenantResource ( '/' . $ path ) ; if ( $ tenantResource ) { return new Pluf_HTTP_Response_File ( $ tenantResource -> getAbsloutPath ( ) , $ tenantResource -> mime_type ) ; } // [OR] check for default spa $ name = Tenant_Service :: setting ( 'spa.default' , 'not-found' ) ; $ spa = Tenant_SPA :: getSpaByName ( $ name ) ; if ( $ spa === null ) { $ spa = Tenant_SpaService :: getNotfoundSpa ( ) ; $ spaName = 'not-found' ; } else { $ spaName = null ; } } if ( preg_match ( '/.+\.[a-zA-Z0-9]+$/' , $ path ) ) { // Looking for file in SPA $ resPath = $ spa -> getResourcePath ( $ path ) ; $ isMain = false ; } else { // [OR]Request is for main file (path is an internal state) $ resPath = $ spa -> getMainPagePath ( ) ; $ isMain = true ; } if ( $ isMain ) { return new Tenant_HTTP_Response_SpaMain ( $ resPath , Pluf_FileUtil :: getMimeType ( $ resPath ) , $ spaName ) ; } else { return new Pluf_HTTP_Response_File ( $ resPath , Pluf_FileUtil :: getMimeType ( $ resPath ) ) ; } }
Load a resource from SPA

@param Pluf_HTTP_Request $request
@param array $match
@return Pluf_HTTP_Response_File|Pluf_HTTP_Response
Load a resource from SPA