Downloads filled forms as a ZIP archive

@param string $callback
@return mixed
@throws Exceptions\InvalidQueryException
@throws Exceptions\InvalidRequestException
188618
public function download(string $callback = "")
    {
        $parameters = [];

        if (!empty($callback) && is_string($callback)) {
            $parameters['callback_url'] = $callback;
        }

        return static::query($this->client, [$this->fillable_form_id, self::DOWNLOAD_URI], $parameters);
    }
107374
public function save($callback)
    {
        foreach ($this as $object) {
            call_user_func($callback, $object);
            if($object->changes()) $object->save();
        }

        return $this;
    }
1153479
public function map(callable $callback): Collection
    {
        $keys = array_keys($this->items);
        $items = array_map($callback, $this->items, $keys);

        return new static(array_combine($keys, $items));
    }
641610
protected function withDuskEnvironment($callback)
    {
        if (file_exists(base_path($this->duskFile()))) {
            if (file_get_contents(base_path('.env')) !== file_get_contents(base_path($this->duskFile()))) {
                $this->backupEnvironment();
            }

            $this->refreshEnvironment();
        }

        $this->writeConfiguration();

        return tap($callback(), function () {
            $this->removeConfiguration();

            if (file_exists(base_path($this->duskFile())) && file_exists(base_path('.env.backup'))) {
                $this->restoreEnvironment();
            }
        });
    }
381856
private function useRedis($callback)
    {
        return PoolManager::use($this->redisPool, function($resource, $redis) use($callback){
            $redis->select($this->redisDb);
            return $callback($resource, $redis);
        });
    }
956006
public function map ($callback)
	{
		if(!is_callable($callback)) {
			throw new \InvalidArgumentException('Invalid (not callable) callback given');
		}

		$result = new self();

		for ($i = 0; $i < $this->count(); $i++) {
			$value = $callback($this->storage[$i]);

			if (null !== $value) {
				$result->push($value);
			}
		}

		return $result;
	}
524344
public function sort(callable $callback = null)
    {
        $items = $this->getArrayCopy();
        $callback ? uasort($items, $callback) : asort($items);
        return new static($items);
    }
327198
public function get($callback = null)
    {
        $result = $this->acquire();

        if ($result && is_callable($callback)) {
            try {
                return $callback();
            } finally {
                $this->release();
            }
        }

        return $result;
    }
651073
function findStoresInZip(zip, callback) {
  var zip5 = typeof(zip) == 'string' ? parseInt(zip, 10) : zip;

  db.collection(stores, function(err, collection) {
    if (err) return callback(err);

    collection.find({zip5:zip5}).toArray(function(err, docs) {
      if (err) return callback(err);
      callback(null, docs);
    })
  })
}
977925
public function each(callable $callback)
    {
        if ($this->isCollection()) {
            foreach ($this->data as $val) {
                $callback($this->box($val));
            }
        } else {
            $callback($this->box($this->data));
        }

        return $this;
    }
1238081
public function filter($callback = null)
    {
        $test = array_filter($this->data, $callback);
        $clone = clone $this;
        return $clone->reset($test);
    }
963703
public function partition($callback)
    {
        $partitions = [new static, new static];
        $callback   = $this->valueAccessor($callback);

        foreach ($this->items as $key => $item) {
            $partitions[(int) ! $callback($item)][$key] = $item;
        }

        return new static($partitions);
    }
1318370
public function afterMatch($callback = null)
        {
            if ($callback !== null) {
                if (!is_callable($callback)) {
                    throw new InvalidArgumentException(
                        sprintf(
                            "The after match callback provided is not valid. Given (%s)",
                            gettype($callback)
                        )
                    );
                }

                $this->afterMatchCallback = $callback;

                return $this;
            }

            return $this->afterMatchCallback;
        }
699329
public function some(callable $callback) {
		$match = false;
		foreach ($this->collection as $element) {
			$match = $match || $callback($element);
		}

		return $match;
	}
1059604
protected function downloadFile($dest, $callback = null)
    {
        $retval = [
            'success' => false,
            'data'    => [],
        ];

        if (is_resource($dest)) {
            $handle = $dest;
            $metadata = stream_get_meta_data($handle);
            $dest = $metadata["uri"];
        } else {
            $dest = rtrim($dest, '/');

            if (file_exists($dest)) {
                if (is_dir($dest)) {
                    $dest = rtrim($dest, '/') . "/{$this['name']}";
                } else {
                    $retval['data']['message'] = "File already exists at '$dest'.";
                    if (is_callable($callback)) {
                        call_user_func($callback, $retval, $dest);
                    }

                    return $retval;
                }
            }

            $handle = @fopen($dest, 'a');

            if (!$handle) {
                throw new \Exception("Unable to open file at '$dest'. Make sure the directory path exists.");
            }
        }

        $response = self::$httpClient->get(
            self::$account->getContentUrl() . "nodes/{$this['id']}/content",
            [
                'headers'    => [
                    'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'],
                ],
                'stream'     => true,
                'exceptions' => false,
            ]
        );

        $retval['data'] = json_decode((string)$response->getBody(), true);

        if ($response->getStatusCode() !== 200) {
            if (is_callable($callback)) {
                call_user_func($callback, $retval, $dest);
            }

            return $retval;
        }

        $retval['success'] = true;

        $body = $response->getBody();
        while (!$body->eof()) {
            fwrite($handle, $body->read(1024));
        }

        fclose($handle);

        if (is_callable($callback)) {
            call_user_func($callback, $retval, $dest);
        }

        return $retval;
    }
1080942
function downloadZip($fileName, $contentType = "application/zip")
    {
        if (!$this->isFinalized) {
            $this->finalize();
        }

        $headerFile = null;
        $headerLine = null;
        if (!headers_sent($headerFile, $headerLine)) {
            if ((ob_get_contents() === FALSE || ob_get_contents() == '') or die("\n<p><strong>Error:</strong> Unable to send file <strong>$fileName.epub</strong>. Output buffer contains the following text (typically warnings or errors):<br>" . ob_get_contents() . "</p>")) {
                if (ini_get('zlib.output_compression')) {
                    ini_set('zlib.output_compression', 'Off');
                }

                header("Pragma: public");
                header("Last-Modified: " . gmdate("D, d M Y H:i:s T"));
                header("Expires: 0");
                header("Accept-Ranges: bytes");
                header("Connection: close");
                header("Content-Type: " . $contentType);
                header('Content-Disposition: attachment; filename="' . $fileName . '";');
                header("Content-Transfer-Encoding: binary");
                header("Content-Length: " . $this->getArchiveSize());

                if (!is_resource($this->zipFile)) {
                    echo $this->zipData;
                } else {
                    rewind($this->zipFile);

                    while (!feof($this->zipFile)) {
                        echo fread($this->zipFile, $this->streamChunkSize);
                    }
                }
            }
            return TRUE;
        }
        return FALSE;
    }
768352
public function reanimateCallback($callback)
    {
        $key = $this->getCallbackKey($callback);

        self::$_baseRealCallbacks[$key] = $callback;

        return $this;
    }