Helper function to get and validate server functions

@param string $strServerCall
@return ezjscServerRouter|null
325664
static function serverCallHelper( $strServerCall )
    {
        $server = ezjscServerRouter::getInstance( $strServerCall );
        if ( !$server instanceof ezjscServerRouter )
        {
            eZDebug::writeError( 'Not a valid ezjscServer function: ' . implode( '::', $strServerCall ), __METHOD__ );
            return null;
        }
        // Make sure the function is present on the class
        if ( !$server->hasFunction() )
        {
            eZDebug::writeError( 'Could not find function: ' . $server->getName() . '()', __METHOD__ );
            return null;
        }
        return $server;
    }
1264447
public function getServer($name)
    {

        // try to match one of the server names with the passed name
        /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $server */
        foreach ($this->getServers() as $server) {
            if ($name === $server->getName()) {
                return $server;
            }
        }
    }
635827
public function server($name = null)
    {
        if (empty($name)) {
            $name = $this->getDefaultServerName();
        }

        if (!isset($this->servers[$name])) {
            $this->servers[$name] = $this->makeServer($name);
        }

        return $this->servers[$name];
    }
837345
private function _getServerOrFail($queueName, $serverTag) : RouterServer
    {
        $server = $this->registry->findServerForQueue($queueName, $serverTag);
        if (!$server) {
            throw new ServerNotConfigured('Server not found for queue: "' .$queueName. '" or tag: "'.$serverTag.'"');
        }
        
        return $server;
    }
1150028
protected function getTokenFromHeader(ServerRequestInterface $request, $headerLine)
    {
        if (!empty($headerLine)) {
            $header = $request->getHeaderLine($headerLine);
            if (!empty($header)) {
                return $header;
            }
        }

        return null;
    }
411377
public function getServer($key = null, $default = null) {
        if (null === $key) {
            return $this->SERVER;
        }

        return (isset($this->SERVER[$key])) ? $this->SERVER[$key] : $default;
    }
620320
public function getWebserviceHost(string $serverId)
    {
        if (!$this->hasServerConfiguration($serverId)) {
            return null;
        }

        return $this->configuration['connections'][$serverId]['host'];
    }
723535
public function getServerCfg($server)
    {
        if (!isset($this->servers[$server])) {
            throw new \Erebot\NotFoundException('No such server');
        }
        return $this->servers[$server];
    }
117885
protected function getServerParam($key, $default = null)
    {
        if (isset($this->server[$key])) {
            return $this->server[$key];
        }

        return $default;
    }
836726
static function checkAccess( $functionName, $user=null )
    {
        if ( $user == null )
        {
            $user = eZUser::currentUser();
        }

        $access = false;
        $accessResult = $user->hasAccessTo( 'webservices' , 'execute' );
        $accessWord = $accessResult['accessWord'];
        if ( $accessWord == 'yes' )
        {
            $access = true;
        }
        else if ( $accessWord != 'no' ) // with limitation
        {
            $currentsa = eZSys::ezcrc32( $GLOBALS['eZCurrentAccess']['name'] );
            $functionName = md5( $functionName );
            $accessws = 1;
            $accesssa = 1;
            foreach ( $accessResult['policies'] as $key => $policy )
            {
                if ( isset( $policy['Webservices'] ) && $accessws === 1 )
                {
                    $accessws = false;
                }
                if ( isset( $policy['Webservices'] ) && in_array( $functionName, $policy['Webservices'] ) )
                {
                    $accessws = true;
                }
                if ( isset( $policy['SiteAccess'] ) && $accesssa === 1 )
                {
                    $accesssa = false;
                }
                if ( isset( $policy['SiteAccess'] ) && in_array( $currentsa, $policy['SiteAccess'] ) )
                {
                    $accesssa = true;
                }
            }
            $access = $accessws && $accesssa;
        }

        return $access;
    }
1071478
public function getRequest()
    {
        if (!$this->getContainer()->has(ServerRequestInterface::class)) {
            $this->getContainer()->share(ServerRequestInterface::class,function(){
                $beforeIndexPosition = strpos($_SERVER['PHP_SELF'],'/index.php');
                /**
                 * If there is some string before /index.php then remove this string from REQUEST_URI
                 */
                if(false !== $beforeIndexPosition && $beforeIndexPosition > 0){
                    $scriptUrl =  substr($_SERVER['PHP_SELF'],0,$beforeIndexPosition);
                    $_SERVER['REQUEST_URI'] = str_replace(['/index.php',$scriptUrl],'',$_SERVER['REQUEST_URI']);
                }
                return  ServerRequestFactory::fromGlobals()->withHeader('content-type', $this->getContentType());
            });
        }

        /** @var ServerRequestInterface $request */
        $request = $this->validateContract($this->getContainer()->get(ServerRequestInterface::class),
            ServerRequestInterface::class);
        return $request;
    }
317303
public function getLeagueGlideServer()
    {
        if (null === $this->server) {
            $config = $this->config + [
                'response' => new LaravelResponseFactory($this->app['request'])
            ];

            $this->server = ServerFactory::create($config);
        }

        return $this->server;
    }
747093
function getServerTags($multicall = false)
    {
        if ($multicall) {
            return $this->execute(ucfirst(__FUNCTION__), array(), $this->structHandler('Tag', true));
        }
        return Structures\Tag::fromArrayOfArray($this->execute(ucfirst(__FUNCTION__)));
    }
1326250
public static function withCallsite($s)
    {
        $bt = debug_backtrace();

        $caller = null;
        do {
            $caller = array_shift($bt);

        } while ($caller && !empty($caller['class']) && $caller['class'] == 'DebugHelper\Logger');

        $file = isset($caller['file']) ? basename($caller['file']) : 'null';
        $line = isset($caller['line']) ? $caller['line'] : 'null';

        return '['.$file.':'.$line.'] '.$s;
    }
786508
public function getServerParam($name, $default = null)
    {
        if (isset($this->serverParams[$name])) {
            return $this->serverParams[$name];
        }

        return $default;
    }
88681
public static function GetCallingURL()
    {
        $sURL = '/';
        if (array_key_exists(self::SESSION_PARAM_NAME, $_SESSION)) {
            $sURL = $_SESSION[self::SESSION_PARAM_NAME];
        } else {
            $sURL = self::getPageService()->getLinkToPortalHomePageAbsolute();
        }

        return $sURL;
    }
325008
public function server(string $key = null, $default = null)
    {
        if (is_null($key)) {
            return $this->getServerParams();
        }
        return $this->getServerParams()[$key] ?? $default;
    }