Generate and output image.
@param  string                   $path   Image path.
@param  array                    $params Image manipulation params.
@throws InvalidArgumentException
430714
public function outputImage($path, array $params)
    {
        $path = $this->makeImage($path, $params);

        header('Content-Type:'.$this->cache->getMimetype($path));
        header('Content-Length:'.$this->cache->getSize($path));
        header('Cache-Control:'.'max-age=31536000, public');
        header('Expires:'.date_create('+1 years')->format('D, d M Y H:i:s').' GMT');

        $stream = $this->cache->readStream($path);

        if (ftell($stream) !== 0) {
            rewind($stream);
        }
        fpassthru($stream);
        fclose($stream);
    }
1272900
public static function image(array $array , $param = array())
    {

        $out = "\n";

        foreach($array as $key => $item){
            if(is_array($item)){
                $out .= Html::image($item[0], $item[1])."\n";
            } else {
                $out .= Html::image($item)."\n";
            }
        }

        return $out;
    }
184698
public static function loadFromPath($path)
	{
		// on test do not load plugins
		if(self::isUnableToRunPlugins())
		{
			return;
		}

		if (!file_exists($path))
		{
			throw new InvalidArgumentException("The path [{$path}] doesn't exist to load plugins.");
		}

		$plugins = require $path;

		foreach ($plugins as $plugin)
		{
			if (array_key_exists($plugin, self::$lookup))
			{
				$plugin = __DIR__ . DS . self::$lookup[$plugin];
			}

			if (file_exists($plugin))
			{
				require_once $plugin;
			}
		}

	}
1275446
public function create($params)
    {
        Util::verifyKeys(self::createSignature(), $params);

        $file = $params['file'];

        if (!is_resource($file)) {
            throw new InvalidArgumentException('file must be a stream resource');
        }

        $payload = [
            'document_upload[kind]' => $params['kind']
        ];
        $path = $this->_config->merchantPath() . '/document_uploads/';
        $response = $this->_http->postMultipart($path, $payload, $file);

        if (isset($response['apiErrorResponse'])) {
            return new Result\Error($response['apiErrorResponse']);
        }

        if (isset($response['documentUpload'])) {
            $documentUpload = DocumentUpload::factory($response['documentUpload']);
            return new Result\Successful($documentUpload);
        }
    }
507881
public function put($path, $params = []){
        $json = json_encode($params);
        
        return $this->_call('PUT', $path, $json);
    }
1315086
protected function createImage($path)
    {
        $path = sprintf('%s/../Resources/images/%s', __DIR__, $path);
        $file = $this->container->get('enhavo_media.factory.file')->createFromPath($path);
        return $this->container->get('enhavo_media.media.media_manager')->saveFile($file);
    }
965962
public function setPath($path)
    {
        if (preg_match(self::PATTERN_MATCH_PATH, $path) !== 1) {
            throw new \InvalidArgumentException('"' . $path . '" is not valid path as part of a URI.', 1184071242);
        }

        $this->path = $path;
    }
478680
public function setOutputPath($path) {
		$dir = pathinfo($path, PATHINFO_DIRNAME);
		$dir = $this->normalizePath($dir);
		
		if (! is_dir($dir)) {
			throw new InvalidPath('Invalid directory: "' . $dir . '"');
		}
		
		if (! is_writable($dir)) {
			throw new InvalidPath('The directory: "' . $dir . '" is unwritable');
		}
		
		if (is_file($path) && ! is_writable($path)) {
			throw new InvalidPath('The File "' . $path . '" exists. but unwritable');
		}
		
		$this->outputFile = $dir . DIRECTORY_SEPARATOR . pathinfo($path, PATHINFO_BASENAME);
		
		return $this;
	}
512739
private function realPath($path)
    {
        $result = realpath($path);
        if ($result === false) {
            throw new \InvalidArgumentException(sprintf('Failed to run realpath(\'%s\')', $path));
        }

        return $result;
    }
1353704
public function image($path, array $options = [])
    {
        $options = optionsParser($options, ['alt' => pathinfo($path, PATHINFO_BASENAME)])
            ->append('class', 'img-fluid')
            ->tooltip();

        return parent::image($path, $options->toArray());
    }
609594
public function getUrl($path, array $params = [])
    {
        $parts = parse_url($this->baseUrl.'/'.trim($path, '/'));

        if ($parts === false) {
            throw new InvalidArgumentException('Not a valid path.');
        }

        $parts['path'] = '/'.trim($parts['path'], '/');

        if ($this->signature) {
            $params = $this->signature->addSignature($parts['path'], $params);
        }

        return $this->buildUrl($parts, $params);
    }
32586
public function setPath($path = null)
    {
        if (is_string($path)) {
            if ($path{0} !== '/') {
                $path = "/$path";
            }
        }
        else if (!is_null($path)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'path'; ".
                " expecting a string or null"
            );
        }
        $this->path = $path;
    }
932504
public function call($path = '', $params = [])
    {
        $default_params = [
            'api_token' => $this->getGuzzleClient()->getConfig('api_token'),
            'aid' => $this->getGuzzleClient()->getConfig('aid'),
        ];

        $params = array_merge($default_params, $params);

        if ($this->getGuzzleClient()->getConfig('method') === 'post') {
            $response = $this->getGuzzleClient()->post('/api/v3' . $path, [
                'verify' => false,
                'form_params' => $params,
            ]);
        } else {
            $response = $this->getGuzzleClient()->get('/api/v3' . $path, [
                'verify' => false,
                'query' => $params,
            ]);
        }
        $data = json_decode($response->getBody()->getContents());

        switch ($data->code) {
            case 401:
            case 404:
                throw new HttpRequestException($data->message);
                break;
            case 400:
            case 805:
            case 5001:
            case 5003:
                throw new InvalidArgumentException($data->message);
                break;
        }

        return $data;
    }
759447
protected function validatePath(string $path): void
    {
        if (empty($path)) {
            $this->fail(new InvalidArgumentException("Path is not specified"));
        }

        if (!is_string($path)) {
            $this->fail(new InvalidArgumentException("Path is not a string"));
        }
    }
1244948
public static function run(array $params = [], ?string $basePath = null): void
    {
        $instance = static::instance();

        $instance->bootstrap($basePath);

        $instance->runConsole($params);
    }
737455
public static function fromString($path)
    {
        if (!file_exists($path)) {
            throw new InvalidArgumentType(
                '$path',
                'existing file',
                $path
            );
        }

        return new static(
            array(
                'inputUri' => $path,
                'fileName' => basename($path),
                'fileSize' => filesize($path),
            )
        );
    }
109300
public function define($name, $path)
    {
        $name = $this->normalizeName($name);

        if (strpos($path, "%$name%") !== false) {
            throw new \InvalidArgumentException('Paths cannot reference themselves.');
        }

        $this->paths[$name] = $path;
    }