src/Middleware/InitStateMiddleware.php
public function getIsFrontend(HTTPRequest $request)
    {
        $adminPaths = static::config()->get('admin_url_paths');
        $adminPaths[] = AdminRootController::config()->get('url_base') . '/';
        $currentPath = rtrim($request->getURL(), '/') . '/';

        foreach ($adminPaths as $adminPath) {
            if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
                return false;
            }
        }

        // If using the CMS preview, do not treat the site as frontend
        if ($request->getVar('CMSPreview')) {
            return false;
        }

        return true;
    }
public function getIsFrontend(HTTPRequest $request)
    {
        $adminPaths = static::config()->get('admin_url_paths');
        $adminPaths[] = AdminRootController::config()->get('url_base') . '/';
        $currentPath = rtrim($request->getURL(), '/') . '/';

        foreach ($adminPaths as $adminPath) {
            if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
                return false;
            }
        }

        // If using the CMS preview, do not treat the site as frontend
        if ($request->getVar('CMSPreview')) {
            return false;
        }

        return true;
    }
public function getIsFrontend ( HTTPRequest $ request ) { $ adminPaths = static :: config ( ) -> get ( 'admin_url_paths' ) ; $ adminPaths [ ] = AdminRootController :: config ( ) -> get ( 'url_base' ) . '/' ; $ currentPath = rtrim ( $ request -> getURL ( ) , '/' ) . '/' ; foreach ( $ adminPaths as $ adminPath ) { if ( substr ( $ currentPath , 0 , strlen ( $ adminPath ) ) === $ adminPath ) { return false ; } } // If using the CMS preview, do not treat the site as frontend if ( $ request -> getVar ( 'CMSPreview' ) ) { return false ; } return true ; }
Determine whether the website is being viewed from the frontend or not

@param  HTTPRequest $request
@return bool
Determine whether the website is being viewed from the frontend or not