public function store(CraftTransformedImageModel $image, bool $isFinalVersion)
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        if (empty($config->storages)) {
            return;
        }

        $path = $image->path;
        $uri = str_replace($config->imagerSystemPath, '', $path);

        foreach ($config->storages as $storage) {
            if (isset(ImagerService::$storage[$storage])) {
                $storageSettings = $config->storageConfig[$storage] ?? null;

                if ($storageSettings) {
                    /** @var ImagerStorageInterface $storageClass */
                    $storageClass = ImagerService::$storage[$storage];
                    $result = $storageClass::upload($path, $uri, $isFinalVersion, $storageSettings);

                    if (!$result) {
                        // todo : delete transformed file. Assume that we'd want to try again.
                    }
                } else {
                    $msg = 'Could not find settings for storage "'.$storage.'"';
                    Craft::error($msg, __METHOD__);
                    throw new ImagerException($msg);
                }
            } else {
                $msg = 'Could not find a registered storage with handle "'.$storage.'"';
                Craft::error($msg, __METHOD__);
                throw new ImagerException($msg);
            }
        }
    }
public function store(CraftTransformedImageModel $image, bool $isFinalVersion)
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        if (empty($config->storages)) {
            return;
        }

        $path = $image->path;
        $uri = str_replace($config->imagerSystemPath, '', $path);

        foreach ($config->storages as $storage) {
            if (isset(ImagerService::$storage[$storage])) {
                $storageSettings = $config->storageConfig[$storage] ?? null;

                if ($storageSettings) {
                    /** @var ImagerStorageInterface $storageClass */
                    $storageClass = ImagerService::$storage[$storage];
                    $result = $storageClass::upload($path, $uri, $isFinalVersion, $storageSettings);

                    if (!$result) {
                        // todo : delete transformed file. Assume that we'd want to try again.
                    }
                } else {
                    $msg = 'Could not find settings for storage "'.$storage.'"';
                    Craft::error($msg, __METHOD__);
                    throw new ImagerException($msg);
                }
            } else {
                $msg = 'Could not find a registered storage with handle "'.$storage.'"';
                Craft::error($msg, __METHOD__);
                throw new ImagerException($msg);
            }
        }
    }
public function store ( CraftTransformedImageModel $ image , bool $ isFinalVersion ) { /** @var ConfigModel $settings */ $ config = ImagerService :: getConfig ( ) ; if ( empty ( $ config -> storages ) ) { return ; } $ path = $ image -> path ; $ uri = str_replace ( $ config -> imagerSystemPath , '' , $ path ) ; foreach ( $ config -> storages as $ storage ) { if ( isset ( ImagerService :: $ storage [ $ storage ] ) ) { $ storageSettings = $ config -> storageConfig [ $ storage ] ?? null ; if ( $ storageSettings ) { /** @var ImagerStorageInterface $storageClass */ $ storageClass = ImagerService :: $ storage [ $ storage ] ; $ result = $ storageClass :: upload ( $ path , $ uri , $ isFinalVersion , $ storageSettings ) ; if ( ! $ result ) { // todo : delete transformed file. Assume that we'd want to try again. } } else { $ msg = 'Could not find settings for storage "' . $ storage . '"' ; Craft :: error ( $ msg , __METHOD__ ) ; throw new ImagerException ( $ msg ) ; } } else { $ msg = 'Could not find a registered storage with handle "' . $ storage . '"' ; Craft :: error ( $ msg , __METHOD__ ) ; throw new ImagerException ( $ msg ) ; } } }
Store transformed image in configured storages

@param CraftTransformedImageModel $image
@param bool                       $isFinalVersion

@throws ImagerException
Store transformed image in configured storages