Creates optimize queue job

@param string $handle
@param string $filePath
@param array  $settings
184163
private function createOptimizeJob(string $handle, string $filePath, array $settings)
    {
        $queue = Craft::$app->getQueue();

        $jobId = $queue->push(new OptimizeJob([
            'description' => Craft::t('imager', 'Optimizing images ('.$handle.')'),
            'optimizer' => $handle,
            'optimizerSettings' => $settings,
            'filePath' => $filePath,
        ]));

        Craft::info('Created optimize job for '.$handle.' (job id is '.$jobId.')', __METHOD__);
    }
1343539
public static function create($handle)
    {
        if (!isset(self::$_pool[$handle])) {
            $classname = self::__getClassName($handle);
            $path = self::__getDriverPath($handle);

            if (!is_file($path)) {
                throw new Exception(
                    __('Could not find Text Formatter %s.', array('<code>' . $classname . '</code>'))
                    . ' ' . __('If it was provided by an Extension, ensure that it is installed, and enabled.')
                );
            }

            if (!class_exists($classname)) {
                require_once $path;
            }

            self::$_pool[$handle] = new $classname;
        }

        return self::$_pool[$handle];
    }
495743
public function add($methods, $route, $settings, $callback = null)
    {
        if($this->cacheLoaded) {
            return true;
        }

        if (is_null($callback)) {
            $callback = $settings;
            $settings = null;
        }

        if (strstr($methods, '|')) {
            foreach (array_unique(explode('|', $methods)) as $method) {
                if ($method != '') {
                    call_user_func_array([$this, strtolower($method)], [$route, $settings, $callback]);
                }
            }
        } else {
            call_user_func_array([$this, strtolower($methods)], [$route, $settings, $callback]);
        }

        return true;
    }
92685
public function seek($handle, int $offset, int $whence = SEEK_SET) : int
    {
        $position = fseek($handle, $offset, $whence);

        if (-1 === $position) {
            throw new FileException('Cannot move pointer to desired position.');
        }

        return $position;
    }
419601
public function writeFile($filePath, array $translations)
    {
        $content = "<?php \n\nreturn [";

        $content .= $this->stringLineMaker($translations);

        $content .= "\n];";

        file_put_contents($filePath, $content);
    }
24418
function (filepath, options, callback) {
        if (typeof options === 'function') {
            callback = options;
            options = undefined;
        }

        options = options || '';
        var args = _.compact([filepath].concat(options.replace(/\ \ /g, ' ').split(' ')));

        logger.debug('cmd:', constant.PROG_OPTIPNG, args.join(' '));

        var proc = spawn(constant.PROG_OPTIPNG, args);

        proc.stdout.on('data', function (data) {
            logger.debug(data.toString());
        });

        proc.stderr.on('data', function (data) {
            logger.debug(data.toString());
        });

        proc.addListener('exit', function (e) {
            if (e) {
                return callback(e);
            }
            callback();
        });
    }
654639
public function writeFile($filePath = null, array $options = [])
    {
        $filePath = empty($filePath)
            ? $this->filePath
            : $filePath;

        if ($this->count()) {
            return (new File())->write($filePath, json_encode($this->getArrayCopy(), JSON_PRETTY_PRINT));
        }
    }
916516
protected function openFile($filePath)
    {
        if (empty($filePath)) {
            throw new \Exception('Input file not defined.');
        } elseif (!file_exists($filePath)) {
            throw new \Exception("File does not exist: {$filePath}");
        }

        $handle = @fopen($filePath, 'r');
        if (false === $handle) {
            throw new \Exception("Unable to open file for reading: {$filePath}");
        }

        return $handle;
    }
507868
public function passthrough( $filePath, $startOffset = 0, $length = false )
    {
        return $this->getHandler( $filePath )->passthrough( $filePath, $startOffset, $length );
    }
1182394
public static function sendFile( $filePath ){
      $config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
      if ( $config->getXSendfile() ){
        CKFinder_Connector_Utils_FileSystem::sendWithXSendfile($filePath);
      } else {
        CKFinder_Connector_Utils_FileSystem::readfileChunked($filePath);
      }
    }
803852
public static function extractCssLineResource($handle, $filenamePath)
    {
        $line = fgets($handle);
        $urls = array();
        if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) {
            foreach ($urls as $source) {
                $orig = self::calculateResourcePathname($filenamePath, $source);
                if(!empty($orig)) {
                    $origPart = preg_split("/Public/i", $orig);
                    $dest = WEB_DIR . $origPart[1];
                    GeneratorHelper::createDir(dirname($dest));
                    if (@copy($orig, $dest) === false) {
                        throw new ConfigException("Can't copy " . $orig . " to " . $dest);
                    }
                } else {
                    Logger::log($filenamePath . ' has an empty origin with the url ' . $source, LOG_WARNING);
                }
            }
        }
    }
1257211
public function readFile($path, $file_handle = NULL) {/*{{{*/
        return $this->_do_request('GET', $path, NULL, NULL, $file_handle);
    }
563445
public static function create($handle, $version, $archiveUrl)
    {
        $result = new static();
        $result->id = null;
        $result->handle = (string) $handle;
        $result->name = '';
        $result->url = '';
        $result->approved = true;
        $result->version = (string) $version;
        $result->archiveUrl = (string) $archiveUrl;
        $result->createdOn = new DateTime();
        $result->processedOn = null;
        $result->failCount = 0;
        $result->lastError = '';

        return $result;
    }
1052865
protected function openHandler($filePath, $mode)
    {
        $fileHandler = @fopen($filePath, $mode);
        if (false === $fileHandler) {
            throw new \RuntimeException("Cannot open the file '$filePath' in '$mode' mode");
        }

        return $fileHandler;
    }
1053678
public static function loadContextFromFile(string $filePath): ContextInterface
    {
        if(!file_exists($filePath)){
            throw new Exception\FileNotFoundException('Context file not found: '.$filePath, 404, null, $filePath);
        }

        $contents = file_get_contents($filePath);
        $context_array = json_decode($contents, true);

        if($context_array === null){
            throw new Exception\MalformedJsonException('JSON sintax error.');
        }

        return new self($context_array);
    }
743449
public function delete( $filePath )
    {
        $map = $this->mapFilePathArray( (array)$filePath );

        $returnValue = true;
        /** @var eZDFSFileHandlerDFSBackendInterface $handler */
        foreach ( $map['handlers'] as $handlerClass => $handler )
        {
            $returnValue &= $handler->delete( $map['files'][$handlerClass] );
        }

        return (bool)$returnValue;
    }
483286
public function optimizeImage($filepath)
    {
        $fileExtension = $this->extensions[mime_content_type($filepath)];

        $transformHandler = config('imageoptimizer.transform_handler');

        if (!isset($transformHandler[$fileExtension])) {
            throw new \Exception('TransformHandler for file extension: "' . $fileExtension . '" was not found');
        }

        $this->get($transformHandler[$fileExtension])->optimize($filepath);
    }