src/FACTFinder/Core/Server/MultiCurlDataProvider.php
public function loadResponse($id)
    {
        if (!isset($this->connectionData[$id]))
            throw new \InvalidArgumentException('Tried to get response for invalid ID $id.');

        // Although this implementation of the data provider generally loads all
        // all available responses at once (basically ignoring the $id
        // parameter), it will not do so if the requested $id does not actually
        // need a connection itself. This allows for other connections to be
        // deferred as long as possible.
        if (!$this->hasUrlChanged($id))
            return;

        $connectionData = $this->connectionData[$id];

        $action = $connectionData->getAction();
        if (empty($action))
        {
            $this->log->error('Request type missing.');
            $connectionData->setNullResponse();
            return;
        }

        // From now on we ignore what parameter has been passed in and just load
        // all available responses.
        $connectionsToFetch = array();
        foreach ($this->connectionData as $id => $connectionData)
        {
            $action = $connectionData->getAction();
            if (!$this->hasUrlChanged($id)
                || empty($action)
            ) {
                continue;
            }

            $httpHeaderFields = $this->prepareHttpHeaders($connectionData);
            $parameters = $this->prepareParameters($connectionData);
            $url = $this->prepareConnectionOptions(
                $connectionData,
                $httpHeaderFields,
                $parameters
            );

            $connectionsToFetch[$id] = array(
                'connection' => $connectionData,
                'url' => $url
            );
        }

        if (count($connectionsToFetch))
        {
            if ($this->usedBefore)
                $this->log->warn('loadResponse() has been called before. You should try to configure all requests '
                               . 'before loading the first response so that all connections can be made in parallel.');

            $this->retrieveResponses($connectionsToFetch);

            $this->usedBefore = true;
        }
    }
public function loadResponse($id)
    {
        if (!isset($this->connectionData[$id]))
            throw new \InvalidArgumentException('Tried to get response for invalid ID $id.');

        // Although this implementation of the data provider generally loads all
        // all available responses at once (basically ignoring the $id
        // parameter), it will not do so if the requested $id does not actually
        // need a connection itself. This allows for other connections to be
        // deferred as long as possible.
        if (!$this->hasUrlChanged($id))
            return;

        $connectionData = $this->connectionData[$id];

        $action = $connectionData->getAction();
        if (empty($action))
        {
            $this->log->error('Request type missing.');
            $connectionData->setNullResponse();
            return;
        }

        // From now on we ignore what parameter has been passed in and just load
        // all available responses.
        $connectionsToFetch = array();
        foreach ($this->connectionData as $id => $connectionData)
        {
            $action = $connectionData->getAction();
            if (!$this->hasUrlChanged($id)
                || empty($action)
            ) {
                continue;
            }

            $httpHeaderFields = $this->prepareHttpHeaders($connectionData);
            $parameters = $this->prepareParameters($connectionData);
            $url = $this->prepareConnectionOptions(
                $connectionData,
                $httpHeaderFields,
                $parameters
            );

            $connectionsToFetch[$id] = array(
                'connection' => $connectionData,
                'url' => $url
            );
        }

        if (count($connectionsToFetch))
        {
            if ($this->usedBefore)
                $this->log->warn('loadResponse() has been called before. You should try to configure all requests '
                               . 'before loading the first response so that all connections can be made in parallel.');

            $this->retrieveResponses($connectionsToFetch);

            $this->usedBefore = true;
        }
    }
TODO: Could this be refactored some more?