mikehaertl\wkhtmlto\Command::addArgs PHP Method

addArgs() public method

public addArgs ( array $args )
$args array args to add to the command. These can be: array( // Special argument 'input' will not get prepended with '--'. 'input' => 'cover', // Special argument 'inputArg' is treated like 'input' but will get escaped // Both 'input' and 'inputArg' can be used in combination 'inputArg' => '/tmp/tmpFileName.html', 'no-outline', // option without argument 'encoding' => 'UTF-8', // option with argument // Option with 2 arguments 'cookie' => array('name'=>'value'), // Repeatable options with single argument 'run-script' => array( 'local1.js', 'local2.js', ), // Repeatable options with 2 arguments 'replace' => array( '{page}' => $page++, '{title}' => $pageTitle, ),
    public function addArgs($args)
    {
        if (isset($args['input'])) {
            // Typecasts TmpFile to filename
            $this->addArg((string) $args['input']);
            unset($args['input']);
        }
        if (isset($args['inputArg'])) {
            // Typecasts TmpFile to filename and escapes argument
            $this->addArg((string) $args['inputArg'], null, true);
            unset($args['inputArg']);
        }
        foreach ($args as $key => $val) {
            if (is_numeric($key)) {
                $this->addArg("--{$val}");
            } elseif (is_array($val)) {
                foreach ($val as $vkey => $vval) {
                    if (is_int($vkey)) {
                        $this->addArg("--{$key}", $vval);
                    } else {
                        $this->addArg("--{$key}", array($vkey, $vval));
                    }
                }
            } else {
                $this->addArg("--{$key}", $val);
            }
        }
    }