Harvest a single repository.

@param string $target   Name of repo (used for target directory)
@param array  $settings Settings for the harvester.

@return void
@throws \Exception
556116
protected function harvestSingleRepository($target, $settings)
    {
        $settings['from'] = $this->opts->getOption('from');
        $settings['until'] = $this->opts->getOption('until');
        $settings['silent'] = false;
        $harvest = $this->factory->getHarvester(
            $target,
            $this->getHarvestRoot(),
            $this->getHttpClient(),
            $settings
        );
        $harvest->launch();
    }
920293
public function move($source, $target)
    {
        // Save file
        $this->filesystem->put(
            $target, file_get_contents($source), $this->media->visibility
        );
    }
1297367
public function php(string $target)
    {
        $php = new PHP();
        $php->process($this->coverage, $target);
    }
153894
public function setup($target)
    {
        $installer = tempnam(sys_get_temp_dir(), 'install');
        $handle = fopen($installer, 'w+');

        $request = $this->guzzle->get('https://getcomposer.org/installer', null, $handle);

        try {
            $response = $request->send();
            fclose($handle);
        } catch (GuzzleException $e) {
            fclose($handle);
            throw new RuntimeException('Unable to download composer install script.');
        }

        if (200 !== $response->getStatusCode()) {
            @unlink($installer);
            throw new RuntimeException('Unable to download composer install script.');
        }

        $dir = getcwd();
        if (!@chdir(dirname($target))) {
            throw new RuntimeException('Unable to move to target directory for composer install.');
        }

        $process = ProcessBuilder::create([$this->phpExecutable, $installer])
            ->setTimeout(300)
            ->getProcess()
        ;

        try {
            $process->run();
            @unlink($installer);
        } catch (ProcessException $e) {
            @unlink($installer);
            throw new RuntimeException('Unable run composer install script.');
        }

        if (!@rename(getcwd() . '/composer.phar', $target)) {
            throw new RuntimeException('Composer install failed.');
        }

        if (!@chdir($dir)) {
            throw new RuntimeException('Unable to move back to origin directory.');
        }

        if (!$process->isSuccessful()) {
            throw new RuntimeException('Composer install failed.');
        }

        if (!file_exists($target)) {
            throw new RuntimeException('Composer install failed.');
        }
    }
951849
public function addTarget($targetName, $target)
    {
        if (isset($this->targets[$targetName])) {
            throw new BuildException("Duplicate target: $targetName");
        }
        $this->addOrReplaceTarget($targetName, $target);
    }
395825
public function saveConfiguration($settings)
    {
        if (file_exists($this->path) && !is_writable($this->path)) {
            throw new Exception('The file "' . $this->path . '" isn\'t writable!');
        }
        
        $content = json_encode($settings);
        
        return file_put_contents($this->path, $content);
    }
928422
public function injectSettings(array $settings): void
    {
        if (isset($settings['security']['authentication']['authenticationStrategy'])) {
            $authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy'];
            switch ($authenticationStrategyName) {
                case 'allTokens':
                    $this->authenticationStrategy = Context::AUTHENTICATE_ALL_TOKENS;
                    break;
                case 'oneToken':
                    $this->authenticationStrategy = Context::AUTHENTICATE_ONE_TOKEN;
                    break;
                case 'atLeastOneToken':
                    $this->authenticationStrategy = Context::AUTHENTICATE_AT_LEAST_ONE_TOKEN;
                    break;
                case 'anyToken':
                    $this->authenticationStrategy = Context::AUTHENTICATE_ANY_TOKEN;
                    break;
                default:
                    throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022);
            }
        }
    }
950531
public function clear(Config $means, Config $target)
    {
        foreach ($target as $key => $value) {
            if ($value instanceof BaseConfig && isset($means[$key])) {
                $this->clear($means[$key], $value);
            } else {
                if (isset($means[$key])) {
                    $target->offsetUnset($key);
                }
            }
        }

        return new BaseConfig($target->toArray());
    }
429723
public function gatherSettings($targetSetting)
  {

    // Load settings if not already available
    $config = self::getProperty('settings', false);
    if (!($config)) {
      $config = self::_gatherSettings(CONFIG_PATH . '/mb_config.json');
      self::setProperty('settings', $config->settings);
    }

    // Optional, method can simply store settings values
    $foundSetting = null;
    if ($targetSetting != null) {
      if (isset($config->settings->$targetSetting)) {
        $foundSetting = $config->settings->$targetSetting;
        unset($foundSetting->__comment);
      } else {
        $foundSetting = null;
      }
    }

    return $foundSetting;
  }
177203
public static function configureOAuth($settings)
    {
        if (!isset($settings['auth_token'])) {
            throw new Exception("'auth_token' must be provided");
        }

        if (!isset($settings['store_hash'])) {
            throw new Exception("'store_hash' must be provided");
        }

        self::$client_id = $settings['client_id'];
        self::$auth_token = $settings['auth_token'];
        self::$store_hash = $settings['store_hash'];

        self::$client_secret = isset($settings['client_secret']) ? $settings['client_secret'] : null;

        self::$api_path = self::$api_url . sprintf(self::$stores_prefix, self::$store_hash);
        self::$connection = false;
    }
406030
private function applyOperations($operations, &$target)
    {
        foreach ($operations as $key => $operation)
        {
            $oldValue = (isset($target[$key]) ? $target[$key] : null);
            $newValue = $operation->_apply($oldValue, $this, $key);
            if (empty($newValue) && !is_array($newValue) && $newValue !== null && !is_scalar($newValue)
            )
            {
                unset($target[$key]);
                unset($this->dataAvailability[$key]);
            } else
            {
                $target[$key] = $newValue;
                $this->dataAvailability[$key] = true;
            }
        }
    }
162370
public static function overload(array $settings)
    {
        if (self::mustLoad()) {
            self::load();
        }
        foreach ($settings as $var=>$val) {
            self::set($var, $val);
        }
    }
681127
public function extract($source, $target)
    {
        if (!$sourceRes = gzopen($source, 'r')) {
            throw new \RuntimeException(sprintf('Unable to read archive file "%s".', $source));
        }
        if (!$targetRes = fopen($target, 'w')) {
            throw new \RuntimeException(sprintf('Unable to write target file "%s".', $target));
        }
        while (!gzeof($sourceRes)) {
            fwrite($targetRes, gzread($sourceRes, $this->bufferSize));
        }
        if (!gzclose($sourceRes)) {
            throw new \RuntimeException(sprintf('Unable to close archive file "%s".', $source));
        }
        if (!fclose($targetRes)) {
            throw new \RuntimeException(sprintf('Unable to close target file "%s".', $target));
        }
    }
1247549
protected function copy($source, $target): void
    {
        // skip, if not exists
        if (!file_exists($source)) {
            return;
        }
        // skip, if target exists
        if (is_file($target) && !is_dir($target)) {
            $this->installer->getIo()->write(
                sprintf('  - File <comment>%s</comment> already exists', $target),
                true,
                IOInterface::VERBOSE
            );
            return;
        }

        // Check the renaming of file for direct moving (file-to-file)
        $isRenameFile = substr($target, -1) !== '/' && !is_dir($source);

        if (file_exists($target) && !is_dir($target) && !$isRenameFile) {
            throw new \InvalidArgumentException('Destination directory is not a directory');
        }

        try {
            if ($isRenameFile) {
                $this->getFilesystem()->mkdir(\dirname($target));
            } else {
                $this->getFilesystem()->mkdir($target);
            }
        } catch (IOException $e) {
            throw new \InvalidArgumentException(
                sprintf('Could not create directory `%s`', $target)
            );
        }

        if (false === file_exists($source)) {
            throw new \InvalidArgumentException(
                sprintf('Source directory or file `%s` does not exist', $source)
            );
        }

        if (is_dir($source)) {
            $finder = new Finder;
            $finder->files()->in($source);

            foreach ($finder as $file) {
                try {
                    $this->getFilesystem()->copy($file, $target . DS . $file->getRelativePathname());
                } catch (IOException $e) {
                    throw new \InvalidArgumentException(
                        sprintf('Could not copy `%s`', $file->getBaseName())
                    );
                }
            }
        } else {
            try {
                if ($isRenameFile) {
                    $this->getFilesystem()->copy($source, $target);
                } else {
                    $this->getFilesystem()->copy($source, $target . '/' . basename($source));
                }
            } catch (IOException $e) {
                throw new \InvalidArgumentException(sprintf('Could not copy `%s`', $source));
            }
        }

        $this->installer->getIo()->write(
            sprintf('  - Copied file(s) from <comment>%s</comment> to <comment>%s</comment>', $source, $target),
            true,
            IOInterface::VERBOSE
        );
    }
659740
public function delete(TargetInterface $target, array $variants = [])
    {
        $success = true;

        if ( ! in_array(static::ORIGINAL, $variants)) {
            $variants[] = static::ORIGINAL;
        }

        foreach ($variants as $variant) {
            if ( ! $this->deleteVariant($target, $variant)) {
                $success = false;
            }
        }

        return $success;
    }
51886
public function crop(&$source, $target, array $action)
    {
        list($x1, $y1, $x2, $y2) = $action['value'];

        if ($this->image->set($source)->crop($x1, $y1, $x2, $y2)->save($target)) {
            $source = $target;
            return true;
        }

        return false;
    }
67999
protected function copyConfigurationFile($source, $target)
    {
        $fs = new Filesystem();
        $fs->copy($source, $target, true);

        if (!$this->output->isQuiet()) {
            $this->output->writeln("Copied $source to $target");
        }
    }