/**
     * @param string $clusterIdentifier
     * @param string $imageType
     * @return string
     */
    public static function getStaticPath( $clusterIdentifier, $imageType )
    {
        if ( !isset( self::$imagePathMapping[$imageType]['staticPath'] ) )
        {
            return null;
        }
        $staticDir = StaticData::directory();

        return $staticDir.'/'.str_replace( '%clusterIdentifier%', $clusterIdentifier, self::$imagePathMapping[$imageType]['staticPath'] );
    }
    /**
     * @param string $cluster
     * @param string $path
     * @param bool $clusterizedPath
     * @return bool|string
     */
    public static function clusterFilePath($cluster, $path, $clusterizedPath = true)
    {
        if (!$cluster)
        {
            $cluster = 'default';
        }

        $staticPath = eZDir::path(array(StaticData::directory(), $cluster, $path));
        $fullPath   = self::fileExists($staticPath);

        if ($fullPath)
        {
            return $clusterizedPath ? $fullPath : $staticPath;
        }

        if ($cluster != 'default')
        {
            return self::clusterFilePath('default', $path);
        }

        return false;
    }
<?php

/* @type $Params string[] */

$clusterIdentifier      = isset( $Params['ClusterIdentifier'] ) ? $Params['ClusterIdentifier'] : ClusterTool::clusterIdentifier();
$applicationIdentifier  = $Params['ApplicationIdentifier'];
$staticDir              = StaticData::directory();
$clusterShort           = substr( $clusterIdentifier, 8 );

$filesToCheck = array(
    StaticData::clusterFilePath( $clusterIdentifier, 'apps/' . $applicationIdentifier . '/appstore_cover.jpg' ),
    StaticData::clusterFilePath( $clusterIdentifier, 'apps/' . $applicationIdentifier . '/appstore_cover.png' ),
    'extension/ezoscar/design/oscar/images/' . $clusterShort . '/apps/' . $applicationIdentifier . '/appstore_cover.jpg',
    'extension/ezoscar/design/oscar/images/' . $clusterShort . '/apps/' . $applicationIdentifier . '/appstore_cover.png',
    'extension/ezoscar/design/oscar/images/common/apps/' . $applicationIdentifier . '/appstore_cover.jpg',
    'extension/ezoscar/design/oscar/images/common/apps/' . $applicationIdentifier . '/appstore_cover.png'
);

foreach ( $filesToCheck as $file )
{
    if ( file_exists( $file ) )
    {
        $image = file_get_contents( $file );
        $fileUtils = eZClusterFileHandler::instance( $file );
        $fileUtils->storeContents( $image );
        header( 'Content-Type: image/jpg' );
        header( 'Content-Length: ' . $fileUtils->size() );
        $fileUtils->passthrough();
        eZExecution::cleanExit();
    }
}
/**
 * Removes icons for given application
 * @param string $appIdentifier Identifier of app
 * @param string $clusterIdentifier Identifier of cluster
 */
function removeIcons()
{
    global $appIdentifier, $clusterIdentifier;
    
    $imageDirPath = eZDir::path( array( StaticData::directory(), $clusterIdentifier, 'apps', $appIdentifier ) );
    eZDir::recursiveDelete($imageDirPath);
}
    /**
     * @return string
     */
    private function setToken()
    {
        $token = array();
        $staticDir = StaticData::directory();
        $outputFile = $staticDir.'/'.$this->tokenFileName;

        if( file_exists( $outputFile ) )
        {
            $token = json_decode( file_get_contents($outputFile), true );
        }
        
        if( !file_exists( $outputFile ) || !isset($token['expiresIn']) || !isset($token['accessToken']) || ($token['expiresIn'] < time()) )
        {
            if( file_exists( $outputFile ) )
            {
                unlink($outputFile);
            }
            $requestData = array(
                "clientId" => $this->clientId,
                "clientSecret" => $this->clientSecret
            );
            
            $query = http_build_query( $requestData );
            $smsApiUrl = "{$this->tokenRequestUrl}?{$query}";
            eZLog::write( "Sending request to: {$smsApiUrl}", 'sms.log' );
            
            $curl = curl_init($this->tokenRequestUrl);                                                                      
            
            curl_setopt_array($curl, array(
                CURLOPT_POST   => true,                                                                   
                CURLOPT_POSTFIELDS => $requestData,                                                                  
                CURLOPT_RETURNTRANSFER => true,
                )
            );
            
            $token = curl_exec( $curl );
            if( $token && isset($token['accessToken']) )
            {
                $logMessage = 'Recieved SMS Service responses: ' . var_export($token, true);
                eZLog::write( $logMessage, 'sms.log' );

                $token = json_decode($token, TRUE);
                $token['expiresIn'] += time() + 300; 
                curl_close( $curl );

                file_put_contents($outputFile, json_encode($token));
                $this->smsToken = $token['accessToken'];
                return true;
            }
            else
            {
                $logMessage = 'Error - Problem with recieved SMS Service responses: ' . var_export($token, true);
                eZLog::write( $logMessage, 'sms.log' );
                return false;
            }
        }
        $this->smsToken = $token['accessToken'];
        return true;
    }