Populate the sources array.

This is called from the constructor, and can be overridden in subclasses.

@param array $sources  The sources as an array of \SimpleSAML\Configuration objects.
@return void
194519
protected function initSources(array $sources)
    {
        foreach ($sources as $source) {
            $this->sources[] = new EntitySource($this, $source);
        }
    }
531794
public function run(array $sources, array $destinations)
    {
        $fileSystem = new Filesystem();
        
        // must have the same sources and destinations number
        if (count($sources) !== count($destinations) && count($destinations) !== 1) {
            throw new Exception('Sources and destinations count mismatch');
        }
        
        // if only one destination is specified for multiple sources, it should be a directory. We should create it if
        // it is not exists
        if (count($destinations) === 1 && !is_dir($destinations[0]) && count($sources) > 1) {
            $fileSystem->mkdir($destinations[0]);
        }
        $copiedFiles = [];
        
        // copy generated files to its destination
        foreach ($sources as $index => $source) {
            
            if (array_key_exists($index, $destinations)) {
                $destination = $destinations[$index];
            } else {
                $destination = $destinations[0];
            }
            
            if (is_dir($destination)) {
                $destination = $this->removeLastSlash($destination);
                
                if ($source instanceof \Symfony\Component\Finder\SplFileInfo && $source->getRelativePath()) {
                    $destination .= '/'.$source->getRelativePath();
                }
                $destination .= '/'.$source->getFilename();
            }
            $this->addNotification('copying "'.$source.'" to "'.$destination.'"');
            
            $fileSystem->copy($source->getRealPath(), $destination);
            $copiedFiles[] = $destination;
        }
        
        return $copiedFiles;
    }
105008
public function setSource($source): void
    {
        if (!$source instanceof Db\Query\Select) {
            throw new Grid\GridException('Source of `SelectSource` should be `Db\\Query\\Select` object');
        }
        parent::setSource($source);
    }
363312
public function load(...$sources)
    {
        if (!$sources) {
            throw new \RuntimeException('Sources must not be empty');
        }

        $this->clear();
        foreach ($sources as $source) {
            switch ($source) {
                case 'query':
                case 'post':
                case 'files':
                case 'cookie':
                    $this->data = array_merge($this->data, $this->request->$source());
                    break;
                default:
                    throw new \RuntimeException('Unknown source: ' . $source);
            }
        }

        if ($session = $this->session->get('input')) {
            $this->session->unset('input');
            if (!$this->data) {
                $this->data   = $session['data'] ?? [];
                $this->errors = $session['errors'] ?? [];
            }
        }
    }
1232962
public void setSources(java.util.Collection<InputSource> sources) {
        if (sources == null) {
            this.sources = null;
            return;
        }

        this.sources = new java.util.ArrayList<InputSource>(sources);
    }
22756
private function mergeArrayValues(array &$source, array &$values)
    {
        foreach ($values as $key => $value) {
            if (isset($source[$key])) {
                $sourceValue = $source[$key];

                if ($sourceValue instanceof IConfigValue) {
                    $sourceValue->set($value);
                } elseif (is_array($sourceValue) || $sourceValue instanceof IConfig) {
                    if (!is_array($value)) {
                        throw new InvalidArgumentException($this->translate(
                            'Value should be an array, "{type}" has been given',
                            ['type' => gettype($value)]
                        ));
                    }

                    if ($sourceValue instanceof IConfig) {
                        $sourceValue->merge($value);
                    } else {
                        $this->mergeArrayValues($sourceValue, $value);
                    }
                } else {
                    throw new UnexpectedValueException($this->translate(
                        'Config source is corrupted.'
                    ));
                }
            } else {
                if (is_array($value)) {
                    $source[$key] = [];
                    $this->mergeArrayValues($source[$key], $value);
                } else {
                    $source[$key] = $this->createConfigValue($value);
                }
            }
        }
    }
649552
public function setCustomHeaders(array $headers)
    {
        foreach ($headers as $k => &$v) {
            if (strpos($v, ':') === false) {
                $v = $k.': '.$v;
            }
        }
        $this->headers = $headers;
    }
217075
public function run(array $sources, array $destinations)
    {
        $updatedSources = [];

        foreach ($sources as $source) {
            // remove .scss extension and add .css extension
            $css = $this->getCacheDir().$source->getBasename('.scss').'.css';
            $this->addNotification('compiling '.$source.' to '.$css);

            // compilation start
            $process = new Process($command = $this->buildCommandString($source));
            $process->run();

            if (!$process->isSuccessful()) {
                throw new Exception(
                    'An error has occurred during the compass compile task : "'.$process->getErrorOutput().""
                    .' (running "'.$command.'")'
                );
            }

            // add css file to destination files
            $updatedSources[] = $css;
        }
        if (count($updatedSources)) {
            // compilation success notification
            $this->addNotification('scss files compilation success');
        }

        return $updatedSources;
    }
1374919
public function populate($data = array())
    {
        if (isset($data['name']) && $data['name'] !== null) {
            $this->name = $data['name'];
        }

        if (isset($data['type']) && $data['type'] !== null) {
            $this->type = $data['type'];
        }
    }
609265
private function processAddSources($sources, $project)
    {
        $groupSources = [];
        foreach ($sources as $source) {
            $dirName = str_replace(\DIRECTORY_SEPARATOR, '/', \dirname($source));
            if (!isset($groupSources[$dirName])) {
                $groupSources[$dirName] = [];
            }
            $groupSources[$dirName][] = basename($source);
        }
        $groups = [];
        foreach ($groupSources as $dirname => $files) {
            $groups[] = 'ADD_SOURCES(configure_module_dirname + "/'.$dirname.'", "'.
                        implode(' ', $files).'", "'.$project.'");';
        }

        return $groups;
    }
1139110
public function addSettings(array $settings)
    {
        foreach ($settings as $key => $value) {
            $this->addSetting($key, $value);
        }
    }
584971
protected function handleSources(array $sources)
    {
        $responses = array();

        foreach ($sources as $source) {
            list($adapter, $request) = $source;
            $responses[] = $this->handleSource($adapter, $request);
        }

        $iterator = new \AppendIterator();

        /** @var Response $response */
        foreach ($responses as $response) {
            $iterator->append($response->getIterator());
        }

        return $iterator;
    }
1197141
public function initDb(array $connections): void{
        $this->db = new Database();
        foreach ($connections as $name => $settings) {
            $this->db->addConnection($settings, $name);
        }
    }
787086
protected function setInvoiceSource($source)
    {
        parent::setInvoiceSource($source);
        switch ($this->invoiceSource->getType()) {
            case Source::Order:
                $this->order = $this->invoiceSource->getSource();
                $this->creditNote = null;
                break;
            case Source::CreditNote:
                $this->creditNote = $this->invoiceSource->getSource();
                $this->order = $this->creditNote->getOrder();
                break;
        }
        $this->shopInvoices = $this->order->getInvoiceCollection();
        $this->shopInvoice = count($this->shopInvoices) > 0 ? $this->shopInvoices->getFirstItem() : null;
    }
155636
public function from($sources)
    {
        if (!$sources) {
            throw new SqlException("A `FROM` clause requires a non empty table.");
        }
        $sources = is_array($sources) ? $sources : func_get_args();
        $this->_parts['from'] += array_merge($this->_parts['from'], $sources);
        return $this;
    }
695007
public function mergeSource(SourceInterface $source): void
    {
        if (array_key_exists($source->sourceId(), $this->sources)) {
            unset($this->sources[$source->sourceId()]);
        } else {
            $this->newSources[$source->sourceId()] = $source;
        }
        $this->sources[$source->sourceId()] = $source;
    }
302892
public function setSource($source)
    {
        if (!$source instanceof Collection) {
            $source = collect($source);
        }

        $this->source = $source;
        return $this;
    }