Set archivers

@param array $archivers An array of archiver

@throws \Exception

@return $this Return $this, allow chaining
496241
public function setArchivers(array $archivers)
    {
        $this->archivers = [];

        foreach ($archivers as $archiver) {
            if (!($archiver instanceof ArchiverInterface)) {
                throw new \Exception('ArchiverManager manage only ' . __NAMESPACE__ . '\\ArchiverInterface');
            }

            $this->archivers[$archiver->getId()] = $archiver;
        }

        return $this;
    }
261957
public static function createArchive(array $files, $archiveFileName){
        $zip = new ZipArchive();
        $result = $zip->open($archiveFileName, ZipArchive::CREATE);
        if ($result !== true)
            throw new Exception('ZipArchive error: '.$result);
        foreach ($files as $localName => $fileName) {
            if ($fileName === null) {
                if ($zip->addEmptyDir($localName) === false)
                    return false;
            } else {
                if ($zip->addFile($fileName, $localName) === false)
                    return false;
            }
        }
        $zip->close();

        return count($files);
    }
1082495
public function setBuilders($builders)
    {
        if (\is_array($builders)) {
            $builders = implode(',', $builders);
        }

        return $this->setQueryValue('Builders', $builders);
    }
218641
public function setItems(array $items)
    {
        $items = $this->getArrayableItems($items);

        foreach ($items as $item) {
            //Ensure the correct type is provided
            $this->checkType($item);
        }

        $this->items = $items;

        return $this;
    }
505609
public function setFormats($formats)
    {
        if (is_array($formats)) {
            $formats = json_encode($formats);
        }

        $this->formats = $formats;

        return $this;
    }
850337
public function setMessages(array $messages): MessagesCollection
    {
        foreach ($messages as $message) {
            if (!$message instanceof Message) {
                throw new \InvalidArgumentException('One of the messages is not instance of ' . Message::class);
            }
            $this->messages[] = $message;
        }

        return $this;
    }
373713
public function setCollections($collections)
    {
        if (!is_array($collections) && !$collections instanceof Traversable) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s: expects an array or Traversable, received "%s"',
                __METHOD__,
                (is_object($collections) ? get_class($collections) : gettype($collections))
            ));
        }

        if ($collections instanceof Traversable) {
            $collections = ArrayUtils::iteratorToArray($collections);
        }

        $this->collections = $collections;
    }
193774
public function withHeaders( array $headers )
	{
		foreach ( $headers as $key => $value )
		{
			$this->headers->set( $key, $value );
		}

		return $this;
	}
1312485
protected static function expandFileList($archiveFiles, $files)
    {
        $newFiles = [];
        foreach ($files as $file) {
            foreach ($archiveFiles as $archiveFile) {
                if (fnmatch($file.'*', $archiveFile))
                    $newFiles[] = $archiveFile;
            }
        }
        return $newFiles;
    }
198747
public function addRepositories(array $repositories)
    {
        foreach ($repositories as $key => $repository) {
            $this->addRepository($key, $repository);
        }
        return $this;
    }
515869
public function archive(array $objectIDs) {
        $requests = [];

        foreach ($objectIDs as $objectID) {
            $requests[] = [
                'method' => 'cmdb.object.archive',
                'params' => [
                    'object' => $objectID
                ]
            ];
        }

        $this->api->batchRequest($requests);

        return $this;
    }
408645
public function setFiles(array $files) {
        if(!$this->setModified('files', $files)->isModified()) {
            return $this;
        }
		$this->files = $files;
		return $this;
    }
384069
public function setAttrs(array $attrs) {
		foreach ($attrs as $attr => $value) {
			$this->setAttr($attr, $value);
		}
		
		return $this;
	}
835871
public function setArchiveLayout($archiveId, $layoutType)
    {
        Validators::validateArchiveId($archiveId);
        Validators::validateLayout($layoutType);
        
        $this->client->setArchiveLayout($archiveId, $layoutType);
    }
190300
private function setToOneIndexes(array $rules): self
    {
        assert($this->debugCheckIndexesExist($rules));

        $this->toOneRules = $rules;

        return $this;
    }
1353391
public function addFiles(array $files)
    {
        $added_files = 0;
        foreach ($files as $localName => $fileName) {
            if (is_null($fileName)) {
                if ($this->zip->addEmptyDir($localName) === false)
                    throw new Exception($this->zip->getStatusString(), $this->zip->status);
            } else {
                if ($this->zip->addFile($fileName, $localName) === false)
                    throw new Exception($this->zip->getStatusString(), $this->zip->status);
                $added_files++;
            }
        }

        // reopen archive to save changes
        $archive_filename = $this->zip->filename;
        $this->zip->close();
        $this->open($archive_filename);

        return $added_files;
    }
768093
public function setFolders($folders)
    {
        $this->set(self::KEY_FOLDERS, $folders);
        $this->provisioningMode = self::PROVISIONING_MODE_FOLDERS;
        return $this;
    }